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.
Related
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'm getting an error while using PyCharm which doesn't allow me to import the pillow module even though I have it installed as a package in the project interpreter. Any help is greatly appreciated!
http://imgur.com/a/DfjC3
While the name of the package is pillow, it is a replacement for PIL and uses the PIL for the name of the base module
the usual way to use pillow is
from PIL import Image
im = Image.open("filename")
See the tutorial, and the documentation
You try to run code with default Python interpreter (/Library/Frameworks/Python.framework/Versions/3.2/bin/python3). You need to configure PyCharm to run Your code with anaconda (~/anaconda/bin/python)
And now (Like #JamesK say) read Pillow tutorial and documentation:
import PIL not import Pillow
For anybody still having trouble with this, I did the following which solved my problem.
Open up your Project Interpreter (⌘ + , on Mac).
At the bottom of this page you'll see the + symbol to the left of the anaconda logo. This will create a pop-up that allows you to search for available packages.
In this new window, search for 'Pillow'.
Click and Install Package.
You should now be able to use "from PIL import Image" or "import Pillow as pil" etc.
After running this command on your terminal
pip install pillow
and you are sure it was installed, but still having same problem of PIL module not found.
Go to your IDE and make sure existing interpreter is set to python interpreter and not anaconda
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 want to do some image resizing with Python. I was trying to do it with the Python Image Library. Am I barking up the right tree?
I tried to install PIL on my Mac from this source http://www.pythonware.com/products/pil/, but it has not been updated since 09. Is there something newer that I should look into?
Installing it gives me an error:
unable to execute gcc-4.0: No such file or directory
error: command 'gcc-4.0' failed with exit status 1
I tried installing the GCC but I think I have 4.2.1
Any help?
Yes PIL is the right Module. but can also try ImageMagick
http://www.imagemagick.org/script/index.php
No PIL 1.1.7 IS the LATEST, Nov 15th 2009
you can check this http://passingcuriosity.com/2009/installing-pil-on-mac-os-x-leopard/
PIL is the right module, PIL 1.1.7 might not be the version you want. :-)
In case the link from dilip kumbham doesn't work, a fork of PIL is available at http://pypi.python.org/pypi/Pillow
That project is mostly about fixing packaging issues as far as I can tell, so it might be easier to install in general.
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