Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django ImageField "Upload a valid image. The file you uploaded was either not an image or a corrupted image."

I have PIL installed, however whenever I try to upload a .png file to an image field through the Django Admin for my model, I get this error:

"Upload a valid image. The file you uploaded was either not an image or a corrupted image."

Other image types work fine. I have tried several different PNG files.

I have tried rebuilding PIL after installing pypng, libpng-dev, etc.. and am on ubuntu server.

like image 625
DantheMan Avatar asked Sep 30 '11 06:09

DantheMan


2 Answers

This issue was solved by using pip to install "pillow" instead of "pil" which allows easy deployment to virtualenv.

like image 169
DantheMan Avatar answered Sep 26 '22 15:09

DantheMan


When you compile PIL it should say if it has been compiled with PNG support or not, but if you have problems installing it yourself, I would recommend that you use the version that comes with ubuntu. It's strangely named but easily installed with:

apt-get install python-imaging
like image 35
gurglet Avatar answered Sep 22 '22 15:09

gurglet