Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32084 closed Bug (invalid)

Can't upload PNG to ImageField

Reported by: terminator14 Owned by: nobody
Component: Uncategorized Version: 2.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by terminator14)

I have an image field like this:

logo_help_text = "Company Logo"
logo = models.ImageField(upload_to='logos/', blank=True, null=True, help_text=logo_help_text)

I can upload lots of different images, in Django Admin to this field without issue. The particular image I was trying to upload had no problems being uploaded, but the image contained a logo with dark letters, and my website background color was dark, so it looked bad. All I did was use Gimp 2.10.4 (MacOS) to change the color of the company name text in the logo to a lighter color, and export the PNG.

According to MacOS' 'file' tool, both the source logo, and the resulting logo are identified exactly the same:

test.png: PNG image data, 1280 x 403, 8-bit/color RGBA, non-interlaced

For some reason, when I try to upload the resulting PNG, Django admin tells me "Upload a valid image. The file you uploaded was either not an image or a corrupted image.".

Image file that can't be uploaded attached.

Attachments (1)

test.png (90.3 KB ) - added by terminator14 4 years ago.
Image that can't be uploaded to ImageField

Download all attachments as: .zip

Change History (5)

by terminator14, 4 years ago

Attachment: test.png added

Image that can't be uploaded to ImageField

comment:1 by terminator14, 4 years ago

Description: modified (diff)

comment:2 by Claude Paroz, 4 years ago

Resolution: needsinfo
Status: newclosed

I suspect an issue with PIL more than with Django. You could set a breakpoint in django.forms.fields.ImageField.to_python() method and check what's going bad there.

comment:3 by terminator14, 4 years ago

comment:4 by Claude Paroz, 4 years ago

Resolution: needsinfoinvalid

Many thanks for the feedback with the bug report link!

Note: See TracTickets for help on using tickets.
Back to Top