Is there a way to make imageutils.py work with SQLFORM.FACTORY? It works
perfectly with database tables but if I upload a picture through
SQLFORM.factory like this:
form = SQLFORM.factory(Field('pic', 'upload', uploadfolder=os.path.join(
request.folder, 'uploads/')), Field('description', 'text'), table_name=
'test')
form.table.pic.requires = RESIZE(50, 50)
The picture is not resized.
On Thursday, May 9, 2013 10:41:14 AM UTC+2, Niphlod wrote:
>
> there's also a /contrib/imageutils.py ready to use.
>
> Il giorno giovedì 9 maggio 2013 07:22:06 UTC+2, weheh ha scritto:
>>
>> There are numerous ways to resize uploaded images. Some are done via the
>> web server. Others are done within the app. For a couple of my apps I use
>> the python PIL package to resize uploaded images to thumbnails and the
>> like. Here's a code fragment that shows how to do it:
>>
>> def resize_image(img_file, indx):
>> from PIL import Image
>> im = Image.open(img_file)
>> im.thumbnail((w, h), Image.ANTIALIAS)
>> return im
>>
>> You then have to use im.save('path', 'jpeg') to get a jpeg out. You also
>> have to do a little extra work to save it to db or do some file management
>> to discard the original, if you so desire.
>>
>>
>>
>> On Thursday, May 9, 2013 5:43:45 AM UTC+8, Dragan Matic wrote:
>>>
>>> Is there a way to automatically optimize and convert images after users
>>> upload it on my web app? I am pretty sure lots of users will upload
>>> uncompressed .bmp pictures or extra large pictures directly from camera. I
>>> think it would be best if I could resize and compress them immediately
>>> after upload. What would be the best way to do it?
>>>
>>
--
---
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/groups/opt_out.