Hi.

If I click on the file link I obtain:
https://my_domain.com/my_app/appadmin/download/db/%5BErrno%202%5D%20No%20such%20file%20or%20directory:%20%27/home/my_folder/webapps/w2p_2_9_12_dev/web2py/applications/my_app/static/uploads/my_table.my_image.844c80079e794fbd.62726f777361626c655f636174616c6f6775652e6a7067.jpg%27

It seems that the my_image path is wrong, but I think it's not.

db.define_table('my_table',
                Field('my_image', 'upload'),
                Field('my_image_thumb', 'upload'))

from PIL import Image

def resize_image(image, size, path, rotate=0):
    if image:
        try:
            img = Image.open('%sstatic/uploads/%s' % (request.folder, image
))
            img = img.convert("RGB")
            img.thumbnail(size, Image.ANTIALIAS)
            img = img.rotate(rotate)
            root, ext = os.path.splitext(image)
            filename = '%s_%s%s' %(root, path, ext)
            img.save('%sstatic/uploads/%s' % (request.folder, filename))
            return filename
        except Exception, e:
            return e
    else:
        return None

db.my_table.my_image_thumb.compute = lambda r: resize_image(r['my_image'], (
250,140), 'thumb')


Do you have an idea?

Il giorno giovedì 1 marzo 2012 01:32:03 UTC+1, pbreit ha scritto:
>
> Oops, make sure to import PIL:
>
> from PIL import Image
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to