Version 4 (modified by anonymous, 10 years ago) (diff)


CookBook - Validate an image size

To check the height and width of an image uploaded via your form, you can implement this method into your or custom manipulator.

You need PIL to be installed.


Here we check that the image is 100*100 pixels.

import Image
import StringIO

def isValideSize(field_data, all_data):
    im =["content"]))
    if im.size != (100,100):
        raise validators.ValidationError, "The image size does not match 100*100"
Back to Top