Changes between Initial Version and Version 1 of CookBookValidateImageSize


Ignore:
Timestamp:
02/24/2006 04:09:59 AM (13 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBookValidateImageSize

    v1 v1  
     1= CookBook - Validate an image height and width =
     2To check the height and width of an image uploaded via your form, you
     3can implement this method into your view.py or custom manipulator.
     4You need PIL [http://www.pythonware.com/products/pil/]  to be installed.
     5== Code ==
     6Here we check that the image is 100*100 pixels.
     7{{{
     8import Image
     9import StringIO
     10
     11def isValideSize(field_data, all_data):
     12    im = Image.open(StringIO.StringIO(field_data["content"]))
     13    if im.size != (100,100):
     14        raise validators.ValidationError, "The image size does not match 100*100 "
     15}}}
Back to Top