DJango's ImageFields uses the PIL verify to check the image.

trial_image = Image.open(file)
trial_image.verify()


See: http://www.pythonware.com/library/pil/handbook/image.htm


On Mar 15, 10:56 pm, john2095 <[email protected]> wrote:
> The documentation states about the ImageField
>
> "Like FileField, but validates that the uploaded object is a valid
> image. Has two extra optional arguments:"
>
> http://docs.djangoproject.com/en/dev/ref/models/fields/#imagefield
>
> I went cruising the source to try and work out what tests are
> implemented to define "a valid image" but didn't get much
> satisfaction. There seemed to be a fair bit of talk about dimensions
> but nothing about much else.  I was thinking/hoping to find something
> which inspected the binary stream to ensure the .jpg/.gif/.png/.bmp
> fit its applicable formats.
>
> Question is "What is the definition of a 'valid image'" in this
> context?"
> and, optionally, where is the source code for that?
>
> t.i.a.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to