Reputation: 46228
I'm using Ubuntu, Django 1.3, Python 2.7.
When I try to upload certain types of image, I get this message:
Upload a valid image. The file you uploaded was either not an image or a corrupted image.
It's happening with PNG and JPG (the formats that I need).
tiff and gif (that I don't and will never care about) are working.
What can I do ?
Upvotes: 4
Views: 2669
Reputation: 3882
I found that this error can be caused by IntegrityError while saving to db
Upvotes: 0
Reputation: 46228
Install PIL !
$ sudo apt-get install python-imaging
(for Ubuntu or other Debian distrib)
Upvotes: 4
Reputation: 12031
If you get this error and you've PIL installed on Ubuntu check that you've jpeg, freetype, zlib libraries installed.
I suggest you also to use apt/aptitude rather than pip/easy_install.
If you really want to install PIL with pip please notice that the PIL setup will not find your installed libraries (libjpg ...) because Ubuntu installs those libs
here -> /usr/lib/x86_64-linux-gnu for 64bit or here -> /usr/lib/x86_32-linux-gnu for 32bit
to fix this you can add this to the setup.py (of course you need to download a copy of PIL from here -> http://www.pythonware.com/products/pil/)
around line 200 (you should see other paths around there)
add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu")
Upvotes: 2
Reputation: 1775
And don't forget about jpeg-lib! Without it PIL willn't understand with what format it can works.
Upvotes: 2