pil

Generating two thumbnails from the same image in Django

Hello, this seems like quite an easy problem but I can't figure out what is going on here. Basically, what I'd like to do is create two different thumbnails from one image on a Django model. What ends up happening is that it seems to be looping and recreating the same image (while appending an underscore to it each time) until it throws ...

Python Image Library, Close method

Hello, I have been using pil for the first time today. And I wanted to resize an image assuming it was larger than 800x600 and also create a thumbnail. I could do either of these tasks separately but not together in one method (I am doing a custom save method in django admin). This returns a "cannot identify image file" error message. T...

Dynamically create and save image with Django and PIL/Django-Photologue

I want to generate a page of html with dynamic content and then save the result as an image as well as display the page to the user. So, user signs up to attend conference and gives their name and org. That data is combined with html/css elements to show what their id badge for the conference will look like (their name and org on top of ...

Django/PIL Error - Caught an exception while rendering: The _imagingft C module is not installed

I'm trying to run a webapp/site on my machine, it's running on OSX 10.6.2 and I'm having some problems: Caught an exeption while rending: The _imagingft C module is not installed Doing import _imagingft in python gives me this: >>> import _imagingft Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: ...

The problem with installing PIL using virtualenv or buildout.

When I install PIL using easy_install or buildout it installs in such way, that I must do 'import Image', not 'from PIL import Image'. However, if I do "apt-get install python-imaging" or use "pip -E test_pil install PIL", all work fine. Here are examples of how I trying to install PIL using virtualenv: # virtualenv --no-site-packages...

How to invert colors of image with PIL (Python-Imaging)?

I need to convert series of images drawn as white on black background letters to images where white and black are inverted (as negative). How can I achieve this using PIL? ...

How do you composite an image onto another image with PIL in Python?

I need to take an image and place it onto a new, generated white background in order for it to be converted into a downloadable desktop wallpaper. So the process would go: 1) Generate new, all white image with 1440x900 dimensions 2) Place existing image on top, centered 3) Save as single image In PIL, I see the ImageDraw object, but no...

Comparing (similar) images with Python/PIL

I'm trying to calculate the similarity (read: Levenshtein distance) of two images, using Python 2.6 and PIL. I plan to us e the python-levenshtein library for fast comparison. Main question: What is a good strategy for comparing images? My idea is something like: Convert to RGB (transparent -> white) (or maybe convert to monochrome?...

image segmentation using pil/any package of python

hi all., i need to segment an image into regions .i'm using pil.i found no module to segment image in pil. I need this segmented regions as a list or dictionary. Actually i'm trying to compare the images for similarity in content aware fashion.for that i need to segment the image. i tried segwin tool but it is drawing another image(whi...

Preserve time stamp when shrinking an image

My digital camera takes pictures with a very high resolution, and I have a PIL script to shrink them to 800x600 (or 600x800). However, it would be nice for the resultant file to retain the original timestamp. I noticed in the docs that I can use a File object instead of a name in PIL's image save method, but I don't know if that will hel...

PIL 1.1.6 saves Photoshop CMYK image colour wrong

I have an image. I want to resize it using PIL, but it comes out like this. Even without a resize, it still messes up the colour. Minimal code: from PIL import Image import os import urllib import webbrowser orig_url = 'http://mercedesclub.org.uk/images/stackoverflow-question/least-popular-colours-_-500-x-500.jpg' temp_fn, _ = url...

something like gimp "fuzzy select" in python/PIL

I have image with some object at not solid background. I want to extract this objects like in gimp using "fuzzy select". This can be an example: http://img249.imageshack.us/gal.php?g=25750902.png Question is what is the best way to do it using python/PIL... ...

Installing PIL 1.1.6. ( error: command 'gcc' failed with exit status 1 )

I'm using Mac OS X Snow Leopard and i can not install PIL 1.1.6. I have faced with: error: command 'gcc' failed with exit status 1 Should I change the version of gcc? Thanks. ...

Installing PIL on Cygwin

I've been struggling all morning to get PIL installed on Cygwin. The errors I get are not consistent with common errors I find using Google. Perhaps a linux guru can see an obvious problem in this output: $ python setup.py install running install running build running build_py running build_ext building '_imaging' extension gcc -fno-str...

Python Imaging: YCbCr problems

Hi, I'm doing some image processing in Python using PIL, I need to extract the luminance layer from a series of images, and do some processing on that using numpy, then put the edited luminance layer back into the image and save it. The problem is, I can't seem to get any meaningful representation of my Image in a YCbCr format, or at lea...

How do you set the image attributes using PIL?

I'm using PIL. I tried using : img.info = {'Buyer':'Text','Copyright':'Text2'} This is not working. Is there an alternate way to do it? ...

PIL to pyvision conversion

How can a PIL image be converted to a Pyvision image? ...

Python problem with resize animate GIF

Hello! I'm want to resize animated GIF with save animate. I'm try use PIL and PythonMagickWand (ImageMagick) and with some GIF's get bad frame. When I'm use PIL, it mar frame in read frame. For test, I'm use this code: from PIL import Image im = Image.open('d:/box_opens_closes.gif') im.seek(im.tell()+1) im.seek(im.tell()+1) im.seek...

Is cropping of jpeg images using the PIL lossless?

A simple questions really. If you crop a jpeg image using the Python Imaging Library, is the resulting image recompressed, or is it lossless? ...

efficiently convert string (or tuple) to ctypes array

I've got code that takes a PIL image and converts it to a ctypes array to pass out to a C function: w_px, h_px = img.size pixels = struct.unpack('%dI'%(w_px*h_px), img.convert('RGBA').tostring()) pixels_array = (ctypes.c_int * len(pixels))(*pixels) But I'm dealing with big images, and unpacking that many items into function arguments ...