HI

db.define_table('logos', 
>
Field('logo', 'upload', uploadfolder='applications/%s/%s' % 
> (request.application, 'uploads'), uploadseparate=True, autodelete=True),
> Field('thumbnail', 'upload', uploadfolder='applications/%s/%s' % 
> (request.application, 'uploads'), uploadseparate=True, autodelete=True, 
> compute = lambda row: thumb(row.logo, 90, 90, 'logos.logo')),
>
) 
>

path = '%suploads/%s/%s/%s' % (request.folder, where, image[start:end], 
> image)
>

"where" depends on the field and table names, table logos and field logo

and thumb is a module for getting a thumbnail of the picture


def thumb( 

>   from gluon import current 
>
  import os
>   from PIL import Image
>   request = current.request 
>   start = len(where)+1 
>   end = len(where)+3
>   img = Image.open('%suploads/%s/%s/%s' % (request.folder, where, 
> image[start:end], image))
>   img.thumbnail((nx, ny), Image.ANTIALIAS)
>   root, ext = os.path.splitext(image)
>   thumb = '%s_%s_%sx%s%s' % (root, name, nx, ny, ext)
>   img.save('%suploads/%s/%s/%s' % (request.folder, where, 
> image[start:end], thumb))
>   #~ print 'thumb', thumb
>   return thumb
>

Regards 

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d8d125ae-ea97-40d1-b9e6-14df78016fdf%40googlegroups.com.

Reply via email to