#24441: core.files.images.get_image_dimensions broken
-------------------------------------+-------------------------------------
     Reporter:  artscoop             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Core (Other)         |                  Version:  1.7
     Severity:  Normal               |               Resolution:
     Keywords:  imagefield,          |             Triage Stage:
  imagefilefield                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by artscoop):

 The field has always been an ImageField, used in production since 2011.
 99.99% of user uploads were valid images, but once I discovered some user
 uploaded an HTML file.
 This time I found another instance breaking because of
 `get_image_dimensions` (on a perfectly valid .bmp file).
 May I provide a history of my usage of the field:

 - First, I used the field as is. People could upload images, and sometimes
 other files (breaking their profile page with a 500)
 - Made numerous tests a few months ago with Django, Magic (MIME discovery)
 and Pillow to find that at least 32-bit bitmaps were not working well with
 Django/Pillow
 - Created a derived `ImageField.to_python` to only accept GIF, PNG and
 JP?G files.
 - Exported the old production site to a local dev version (with a fixed
 ImageField). Past bogus files are still there and break loudly as soon as
 Django finds the image field.

 I don't even blame Pillow. I really think `get_image_dimensions` is bogus
 because it should never return `None`. Instead it should return a tuple
 with empty dimensions or error dimensions `(0, 0) or (1, 1)` because the
 calling function simply chokes when receiving a `None` (instead of dealing
 with `None` it *always* assumes it's a tuple, and *this* is a bug, either
 in the calling function or the called one)

--
Ticket URL: <https://code.djangoproject.com/ticket/24441#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.81351992cf9927caa86670a36f18750d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to