>
> def makeThumbnail(dbtable,ImageID,size=(150,150)):
>
    try:
>         thisImage=db(dbtable.id==ImageID).select()[0]
>         import os, uuid
>         from PIL import Image
>     except: return
>     if thisImage.image == "":
>         return
>     im=Image.open(request.folder + 'uploads/' + thisImage.image)
>     im.thumbnail(size,Image.ANTIALIAS)
>     thumbName='product.image.%s.jpg' % (uuid.uuid4())
>     im.save(request.folder + 'uploads/' + thumbName,'jpeg')
>     thisImage.update_record(thumbnail=thumbName)
>

Hmm, I don't see how automatic retrieval ever would have worked in the past 
if that's the code you use to store the thumbnails.

Anyway, instead of storing the image manually, you should let web2py handle 
it:

import cStringIO
thumb = cStringIO.StringIO()
im.save(thumb, format='JPEG') # Save the PIL image to the StringIO object.
thisImage.update_record(thumbnail=dbtable.thumbnail.store(thumb, thumbName))

If you want to stick with your custom storage, then you should create a 
custom_retrieve function for the "thumbnail" field to override the default 
retrieve method of the field:

def retrieve_thumb(name, path):
    [get the file]
    return (filename, stream)

db.define_table('mytable',
    ...
    Field('thumbnail', 'upload', custom_retrieve=retrieve_thumb))

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to