pil

Python PIL cannot locate my "libjpeg" ...simple installation issue

I cannot use PIL because it cannot find my libjpeg! First, I installed PIL default. And when I ran the selftest.py, it gave me: IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage Test Failed 1 failures. *** 1 tests of 57 failed. Then, I followed instructions online to change PIL's s...

Why is it that my thumbnail PIL function won't work the 2nd time?

def create_thumbnail(f, width=200, height=100): im = Image.open(f) im.thumbnail((width, height), Image.ANTIALIAS) thumbnail_file = StringIO() im.save(thumbnail_file, 'JPEG') thumbnail_file.seek(0) return thumbnail_file It seems that my error is "IOError: cannot identify image file"...based on my traceback log....

App Engine image resize without maintaining aspect ratio?

When I call resize on images using app engine, they maintain their aspect ratio - I don't end up with the size I ask for. I'm trying to make rectangular pixel NTSC images from square pixel sources, so I don't want this behaviour I want to take an image that is 720x540 and resize it to 720x480 but what I actually end up when ask for the...

Python Image Library ellipse with wide outline

When creating an ellipse with PIL, is it possible to have a thicker/wider outline? Currently, I'm trying to do canvas.ellipse(box, outline=colour, fill=None), but would like to be able to give the outline parameter a width. ...

Python Image Uploading with AjaxUpload

I'm trying to use AjaxUpload with Python: http://valums.com/ajax-upload/ I would like to know how to access the uploaded file with Python. On the web site, it says: * PHP: $_FILES['userfile'] * Rails: params[:userfile] What is the Syntax for Python? request.params['userfile'] doesn't seem to work. Thanks in advance! Here is my c...

Snow Leopard Python 2.6 problems getting PIL to work

I installed libjpeg and PIL, but when I try to save a JPG image, I always get this error: ImportError: The _imaging C module is not installed Any help much appreciated! I tried to import _imaging w/ Python interpreter to see what's wrong and got this: >>> import _imaging Traceback (most recent call last): File "<stdin>", line 1...

Is it possible to reduce an image's depth using PIL?

Is it possible to reduce the depth of an image using PIL? Say like going to 4bpp from a regular 8bpp. ...

What is needed to add an paperprint-like effect to photos in python?

I want to transform photos in python to look like this: taken from doctype.com I will use it in django, PIL is installed. How can I achieve this? ...

How to iterate over columns of an image?

I want to transform images like this to add an effect to pictures in django as described here. I decided to implement it as a process for the great django-imagekit/photologue My knowledge of PIL isn't very good, so my question is How to intend a column of pixels by a sinus-offset in PIL? any hints (code, lins, general thoughts) ar...

PIL vs Python-GD for crop and resize

Dear Stackoverflow'ers, I am creating custom images that I later convert to an image pyramid for Seadragon AJAX. The images and image pyramid are created using PIL. It currently take a few hours to generate the images and image pyramid for approximately 100 pictures that have a combined width and height of about 32,000,000 by 1000 (ye...

Histogram in matplotlib gets cropped at top

I have a Python program that generates a histogram using matplotlib. The problem is that the images that are generated sometimes get cropped at the top. First, here's the relevant code excerpt, where plt is matplotlib.pyplot and fig is matplotlib.figure: plt.hist(grades, bins=min(20, maxScore), range=(0,maxScore), figure=fig.Figure(fi...

Scaling images stored at S3

I'm in a situation where I need to push image storage for a number of websites out to a service that can scale indefinitely (S3, CloudFiles, etc.). Up until this point we've been able to allow our users to generate custom thumbnail sizes on the fly using Python's Imaging library with some help from sorl-thumbnail in Django. By moving ou...

SANE + Python, missing device after close statement

I'm having a trouble using SANE on Python to scan an image on a Kodak scanner. The real headache comes to when I close the scanner device after getting the image, it just disappears from the SANE Devices lists until I restarted the Python interpreter, making impossible to scan another image. It just acts like that with this scanner, I'...

In Python, Python Image Library 1.1.6, how can I expand the canvas without resizing?

I am probably looking for the wrong thing in the handbook, but I am looking to take an image object and expand it without resizing (stretching/squishing) the original image. Toy example: imagine a blue rectangle, 200 x 100, then I perform some operation and I have a new image object, 400 x 300, consisting of a white background upon wh...

Preserving extent from the old image

I am using PIL 1.1.6, python 2.5 on windows platform. In my program I am performing point operation (changing the pixel values) and then saving the new image. When I am loading the new and old image, they are not in the same extent. How to impose the extent of old image to the new image? RE edited question: My code is: img = Image.o...

python image recognition

hi, what I want to do is a image recognition for a simple app: given image (500 x 500) pxs ( 1 color background ) the image will have only 1 geometric figure (triangle or square or smaleyface :) ) of (50x50) pxs. python will do the recognition of the figure and display what geometric figure is. any links? any hints? any API? thxs :) ...

How to use PIL to resize and apply rotation EXIF information to the file ?

Hello, I am trying to use Python to resize picture. With my camera, files are all written is landscape way. The exif information handle a tag to ask the image viewer to rotate in a way or another. Since most of the browser doesn't understand this information, I want to rotate the image using this EXIF information and keeping every othe...

PIL Best Way To Replace Color?

I am trying to remove a certain color from my image however it's not working as well as I'd hoped. I tried to do the same thing as seen here http://stackoverflow.com/questions/765736/using-pil-to-make-all-white-pixels-transparent however the image quality is a bit lossy so it leaves a little ghost of odd colored pixels around where what ...

How do I create an OpenCV image from a PIL image?

I want to do some image processing with OpenCV (in Python), but I have to start with a PIL Image object, so I can't use the cvLoadImage() call, since that takes a filename. This recipe (adapted from http://opencv.willowgarage.com/wiki/PythonInterface) does not work because cvSetData complains argument 2 of type 'void *' . Any ideas? ...

Convert PyQt to PIL image

I have an image in a QImage and I want to process it in PIL before I display it. While the ImageQT class lets me convert a PIL Image to a QImage, there doesn't appear to anything to go from a QImage to a PIL Image. ...