#24948 closed Bug (fixed)
BMP Image File treated as invalid
| Reported by: | jerzyk | Owned by: | Andriy Sokolovskiy |
|---|---|---|---|
| Component: | Forms | Version: | 1.8 |
| Severity: | Release blocker | Keywords: | bmp, image |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
when assigning a .bmp (windows bitmap) image to an ImageField field, django reports error, responsible line, that raises an error is django/forms/fields.py:695 (to_python)
f.content_type = Image.MIME[image.format]
file is validated properly (opened, validated) and at the and, it's mime_type is detected by using a dictionary Image.MIME.
This dictionary is not documented and does not contain entries for BMP file, so it may be assumed that Django is using it's private api.
There are two options - push on Pillow to make this public API and fix an issue or use different method to find mime-type (e.g. python's standard mimetypes library)
Change History (5)
comment:1 by , 10 years ago
| Severity: | Normal → Release blocker |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
| Has patch: | set |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
https://github.com/django/django/pull/4869
I think setting content_type to None will be enough.
comment:3 by , 10 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
It's a regression in 1.8 (#10935), so qualifies for a backport. At least we could catch the exception and set
f.content_type = Nonein that case.