finally I realize that I cannot work with local files... so I have to
think to another solution, one could be a real multiple file upload
widget that actually is not yet implemented in web2py or work with
file archives... other suggestions?
thanks a lot
Manuele
2011/3/30 pbreit <[email protected]>:
> I don't totally understand the question but perhaps this will help. Below is
> in my model which takes an image and then creates a thumbnail by passing it
> to a function (also in the model).
>
> db.define_table('item',
> Field('image', 'upload', uploadfolder=request.folder+'static/uploads'),
> Field('image_thumb', 'upload',
> uploadfolder=request.folder+'static/uploads',
> compute=lambda r: resize_image(r['image'], (150,130), 'thumb')))
> def resize_image(image, size, path):
> from PIL import Image
> import os.path
> try:
> img = Image.open('%sstatic/uploads/%s' % (request.folder, image))
> img.thumbnail(size, Image.NEAREST)
> root, ext = os.path.splitext(image)
> filename = '%s_%s%s' %(root, path, ext)
> img.save('%sstatic/uploads/%s' % (request.folder, filename))
> except Exception, e:
> return e
> else:
> return filename
--
Manuele Pesenti
[email protected]
https://sites.google.com/site/manuelepesenti/