[web2py] Re: resize image validator using PIL

2013-11-18 Thread Francisco Costa
its better to keep the TemporaryFile so that the image filesize gets updated, otherwise the image filesize will be the same as the original and it should be smaller On Thursday, September 2, 2010 12:30:49 PM UTC+1, kachna wrote: > > One more update. "tempfile.TemporaryFile()" in not needed. > >

[web2py] Re: resize image validator using PIL

2010-09-02 Thread kachna
One more update. "tempfile.TemporaryFile()" in not needed. def __call__(self, value): import Image import cgi try: im = Image.open(value.file) print im.size, im.format

[web2py] Re: resize image validator using PIL

2010-09-02 Thread kachna
Thanks for hint. Here is my working solution. It takes lot of time. def __call__(self, value): import Image import cgi import tempfile try: im = Image.open(value.file) print im

[web2py] Re: resize image validator using PIL

2010-09-01 Thread mdipierro
not 100% thread safe but ok in most of the cases. On Sep 1, 5:57 pm, Jose wrote: > What I did was the following: > 1) upload image > 2) resize the image on the server > > if form.accepts(request.vars, session): >         import os >         import my_module_resize > >         id = form.vars.id >

[web2py] Re: resize image validator using PIL

2010-09-01 Thread Jose
What I did was the following: 1) upload image 2) resize the image on the server if form.accepts(request.vars, session): import os import my_module_resize id = form.vars.id row= mytable[id] path = os.path.join(os.getcwd(), 'applications', 'myapp', 'uploads',

[web2py] Re: resize image validator using PIL

2010-09-01 Thread mdipierro
This is a bit more complex than it seems because upload expects a ci.FieldStorage object so the validator __call__ should return a cgi.FieldStoarge. On Sep 1, 3:50 pm, kachna wrote: > Hi, > I am trying to write validator to resize my image before storing in DB > field. > > class RESIZE_IMG(object