CARVIEW |
Select Language
HTTP/2 200
server: nginx
content-type: text/html;charset=utf-8
cache-control: must-revalidate
expires: Fri, 01 Jan 1999 00:00:00 GMT
set-cookie: trac_form_token=6aeb888bb16c14dd29c09829; HttpOnly; Path=/; Secure
set-cookie: trac_session=e08b596fdfae3782bbd18cb3; expires=Tue, 21 Oct 2025 05:44:43 GMT; HttpOnly; Path=/; Secure
strict-transport-security: max-age=31536000; includeSubDomains; preload
permissions-policy: interest-cohort=()
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
accept-ranges: bytes
via: 1.1 varnish, 1.1 varnish
date: Wed, 23 Jul 2025 05:44:43 GMT
x-served-by: cache-fra-eddf8230084-FRA, cache-bom-vanm7210035-BOM
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1753249484.653443,VS0,VE335
vary: Accept-Encoding
CookBookValidateImageSize – Django
Back to Top
Django
The web framework for perfectionists with deadlines.
Issues
CookBook - Validate an image size
django version : 0.91
To check the height and width of an image uploaded via your form, you can implement this method into your view.py or custom manipulator.
You need PIL https://www.pythonware.com/products/pil/ to be installed.
Code
Here we check that the image is 100*100 pixels.
import Image import StringIO def isValidSize(field_data, all_data): im = Image.open(StringIO.StringIO(field_data["content"])) if im.size != (100,100): raise validators.ValidationError, "The image size does not match 100*100"
Last modified
19 years ago
Last modified on Feb 27, 2006, 4:56:51 AM
Note:
See TracWiki
for help on using the wiki.
Download in other formats:
Django Links
Learn More
Get Involved
Follow Us
- Hosting by In-kind donors
- Design by Threespot &
© 2005-2025 Django SoftwareFoundation unless otherwise noted. Django is a registered trademark of the Django Software Foundation.