Long ago user Voltron and Denes has done this using the PIL module.
Here is an extract of a previous post:

Try the following code as your db.py model and insert a new image
using the appadmin, this works for me (v369 & PIL 1.1.6 on windows):

import Image
class IS_IMAGE(object):
 def __init__(self,error_message='not accepted!'):
   self.maxw=300
   self.maxh=200
   self.em=error_message
 def __call__(self,value):
   print value.__class__
   print value.filename
   print value.type
#     try:
   img=Image.open(value.file)
#     except:
#       return(value,self.em)
   print img.format,img.size
   if img.format in ['JPG','JPEG','jpg','jpeg']:
     imgsize=img.size
     if imgsize[0]>self.maxw:
       return(value,self.em)
     elif imgsize[1]>self.maxh:
       return(value,self.em)
     return(value,None)
   return(value,self.em)


On Jun 26, 12:21 pm, annet <annet.verm...@gmail.com> wrote:
> In my application I allow users to upload images. I would like to
> validate the images on size (xx KB) and dimensions (width xxx and
> height xxx). I wonder whether any one has done this before, and what
> is the best way to proceed.
>
> Kind regards,
>
> Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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