I'm trying to upload an image using normal form for normal admin for normal model with normal image field.
thumb = fields.ThumbnailField(upload_to=make_upload_path, sizes=settings.VIDEO_THUMB_SIZE, blank=True, null=True)
But I'm getting an error:
Upload a valid image. The file you uploaded was either not an image or a corrupted image.
But my images are valid! I've tried at least ten jpegs and getting the error. What can I do?
You probably have PIL (Python Imaging Library) installed without JPEG support. If you don't have the libjpeg header files it'll happily compile and install, just with no JPEG support. You need to uninstall PIL, make sure you install libjpeg and the libjpeg development header files, and then reinstall PIL. How you do this depends entirely on your platform.
Related
I am using the conda environment and I cannot load the white noise library, but it says that the library is installed.
enter image description here
enter image description here[[[[enter image description here](https://i.stack.imgur.com/QcVTw.png)](https://i.stack.imgur.com/PXIy9.png)](https://i.stack.imgur.com/6qMSC.png)](https://i.stack.imgur.com/TNOYx.png)
I try all, but i can't fix this error
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 ?
Install PIL !
$ sudo apt-get install python-imaging
(for Ubuntu or other Debian distrib)
And don't forget about jpeg-lib! Without it PIL willn't understand with what format it can works.
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")
I found that this error can be caused by IntegrityError while saving to db
i want to make this work on freebsd
I am always receiving this error when trying to generate a thumbnail with the easy_thumbnails module:
InvalidImageFormatError: The source file does not appear to be an image
I have tried installing PIL from source by specifying the library
paths in the setup.py file
I have tried installing PILLOW instead.
I tried it both on python27 and python26
I tried installing PIL with easy install instead of pip, both on PILLOW and PIL
I have py-imaging installed and my tests on the PIL library show ok
btw the exact python code works fine on a RHEL box
any other suggestions for things to try here
thank you in advance
That's usually a sign that PIL is not finding the libraries for the image type. You mentioned that you installed from source with the library paths specified. Did you include all the libraries? Do you have the JPEG port installed? Did you try installing PIL from ports. The port defaults to include JPEG, ZLIB, Freetype2, etc.
I installed PIL and all the jpeg dependencies for using the jpeg module in PIL
docs : http://docs.python.org/library/jpeg.html
I want to use the jpeg.compress() method stated there. But when i installed PIL i wasn't able to find the jpeg module.
can someone tell me how i can use the jpeg.compress() method in my script.
Or is there any alternative to this?
PIL can be a beast to install at times. It's very likely it wasn't configured (correctly) with libjpeg.
If it's just a matter of not installing, or PIL not seeing libjpeg, take a look here:
Python PIL cannot locate my "libjpeg"
I'm not sure what platform you're working on, but each seems to have its own set of unique pitfalls when building PIL. My suggestion is to give "Pillow" a shot, it makes the PIL install process much more user friendly:
http://pypi.python.org/pypi/Pillow
You just need to have a working libjpeg install before running the Pillow install, and you should be off to the races.
The jpeg module and PIL module are independent and have no connection to each other. The documentation lists PIL as a replacement for jpeg. You'll need to install the jpeg module separately.
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 ?
Install PIL !
$ sudo apt-get install python-imaging
(for Ubuntu or other Debian distrib)
And don't forget about jpeg-lib! Without it PIL willn't understand with what format it can works.
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")
I found that this error can be caused by IntegrityError while saving to db