I forget:

from PIL import Image

On 9 Ott, 15:49, leone <handja...@gmail.com> wrote:
> Solved:
>
> if form.accepts(request.vars, session, keepvalues=True,
> onvalidation=WriteThumb):
>          .........
>
> def WriteThumb(form):
>     i = cStringIO.StringIO()
>     o = cStringIO.StringIO()
>     i.write(form.vars.imgfile.value)
>     i.seek(0)
>     im = Image.open(i, 'r')
>     im.thumbnail((100,100),Image.ANTIALIAS)
>     im.save(o,'jpeg')
>     form.vars.thumbnail = base64.b64encode(o.getvalue())
>     o.close()
>     i.close()
>
> <img src="data:image/jpeg;base64,{{=row['thumbnail']}}"
>                                     alt="Thumbnail photo"  />
>
> On 9 Ott, 14:48, leone <handja...@gmail.com> wrote:
>
>
>
> > excuse me: onvalidation not onvalidate.
>
> > On 9 Ott, 14:20, leone <handja...@gmail.com> wrote:
>
> > > I have questions about SQLFORM onvalidate.
> > > Before inserting a row I have to resize an image by PIL and push
> > > b64encoded bytes on a blob field.
> > > So I have defined onvalidate=DoSomething in SQLFORM.
> > > DoSomething has form as input arg, resize image as thumbnails, encode
> > > it and push in form.vars.myblob
> > > (or db.mytable.myblob???).
> > > The new record is OK, but blob field is empty.
> > > Can someone orient me?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to