Its working fine now. So I thought why not expand it create a thumbnail and
displaying it. to reduce loading speed of the website.
So I used this nice code from web2py slices:
def makeThumbnail(dbtable,ImageID,size=(150,150)):
try:
thisImage=db(dbtable.id==ImageID).select()[0]
import os, uuid
from PIL import Image
except: return
im=Image.open(request.folder + 'uploads/' + thisImage.image)
im.thumbnail(size,Image.ANTIALIAS)
thumbName='uploads.thumb.%s.jpg' % (uuid.uuid4())
im.save(request.folder + 'uploads/' + thumbName,'jpeg')
thisImage.update_record(thumb=thumbName)
return
def uploadimage():
dbtable = db.images #images table name
if len(request.args):
records = db(dbtable.id==request.args[0]).select()
if len(request.args) and len(records):
form = SQLFORM(dbtable, records[0], deletable=True)
else:
form = SQLFORM(dbtable)
if form.accepts(request.vars, session):
response.flash = 'form accepted'
makeThumbnail(dbtable,form.vars.id,(175,175))
elif form.errors:
response.flash = 'form has errors'
## Quick list just to demonstrate...
list = crud.select(dbtable)
return dict(form=form,list=list)
and I added: this to my Image table:
Field('thumb','upload',writable=False,readable=False),
The thumbnail appears in the folder upload as I expected the Image displays
but when I want to display the thumbnail. I get no image at all even though the
origianl displays the db entry for thumbnail is correct.
can anyone help I just have no clue why it wouldn't display.
to display I used
{{=IMG(_src=URL('download',args=Article.TopImage.thumb),_style="display:block;")}}
--