pil

Python Imaging Library save function syntax

Simple one I think but essentially I need to know what the syntax is for the save function on the PIL. The help is really vague and I can't find anything online. Any help'd be great, thanks :). ...

How do I find images with a similar color using Python and PIL?

I have a lot of images in a folder, and I would like to find images with a similar color to a pre chosen image. I would like to be able to do something like: python find_similar.py sample.jpg and have that return something like: 234324.jpg 55.jpg 9945.jpg 345434.jpg 104.jpg Is this doable? ...

python PIL install on shared hosting

I'm going to deploy a django app on a shared hosting provider. I installed my own python in my home, it works fine. My promblem comes with the installation of PIL, i have no support for JPEG after the compile process. I know that the compiler dont find "libjpeg", so i tried to install it at my home, i download the tar.gz and compile it ...

Python, PIL, crop problem

Can't seem to get crop working correctly, problem is, it crops a region of correct dimensions, but always from top left corner (0, 0), instead of from my passed coordinates. image = Image.open(input) region = image.crop((1000,400,2000,600) region.save(output) In image.py from PIL, method _ImageCrop I've printed out.. : print x0, y0, ...

Python PIL: how to write PNG image to string?

I have genereated image by PIL. How can I save it to string in memory? Image.save() method requires file. I'd like to have number of such images stored in dictionary. ...

How to Alter Photographed Document to Look "Scanned"

How can I do this in Python/PIL? I.e., given the four points of an offset rectangle (a photographed document), make it look flat on as if it were scanned. Is there a simple algorithm for it? Also, are there any other manipulations I should do to make it look more "scan-like"? I want to make a simple version of this program for myself ...

How to Make an Image Uniform Brightness (using Python/PIL)

I want to take an image of a document that was photographed and make it look like it was scanned. Since a scanner will put a constant light source over the whole document, I want to achieve that effect on a photo of a document. The desired effect would be to remove any shadows or areas of low light (or at least make them less noticeabl...

How can I blue-box an image?

I have a scanned image which is basically black print on some weird (non-gray) background, say, green or yellow (think old paper). How can I get rid of the green/yellow and receive a gray picture with as much of the gray structure of the original image intact? I.e. I want to keep the gray around the letters for the anti-aliasing effect ...

unsubscriptable object

Hi I'm using PIL im = Image.open(teh_file) if im: colors = im.resize( (1,1), Image.ANTIALIAS).getpixel((0,0)) # simple way to get average color red = colors[0] # and so on, some operations on color data The problem is, on a few (very few, particulary don't know why those exactly, simple jpegs) I get 'unsubscri...

Using PiL to take a screenshot of HTML/CSS

I want to enable a user on a website to upload an image, and write some text over it. Also, they should be able to crop/scale/move the image and text. For that stuff, I can do it in jQuery. After they've made the image the way they want it, is there a way i can take a screenshot of that image (using PiL) and save it on the server? Wh...

How to check if an RGB image contains only one color?

I'm using Python and PIL. I have images in RGB and I would like to know those who contain only one color (say #FF0000 for example) or a few very close colors (#FF0000 and #FF0001). I was thinking about using the histogram but it is very hard to figure out something with the 3 color bands, so I'm looking for a more clever algorithm. An...

Building Python PIL for JPEG looks okay, but fails the selftest

I'm on Fedora Core 6 (64 bit) after "yum install libjpeg-devel" I have downloaded and built PIL. It gives the message: --- JPEG support ok Looks like JPEG built okay, but when running selftest.py: IOError: decoder jpeg not available Why would it appear to have built correctly, but fail the selftest? ...

What's a more elegant rephrasing of this cropping algorithm? (in Python)

I want to crop a thumbnail image in my Django application, so that I get a quadratic image that shows the center of the image. This is not very hard, I agree. I have already written some code that does exactly this, but somehow it lacks a certain ... elegance. I don't want to play code golf, but there must be a way to express this shor...

Looking for a better alternative to PIL for basic image file I/O and processing in Python?

Are there better alternatives to PIL (Python Imaging Library - http://is.gd/3OPI ) for basic image file I/O and processing in Python? ...

Writing text with carriage return to image in Python using PIL

Hello, I have a python script that is writing text to images using the PIL. Everything this is working fine except for when I encounter strings with carriage returns in them. I need to preserve the carriage returns in the text. Instead of writing the carriage return to the image, I get a little box character where the return should be. ...

Using PIL to make all white pixels transparent?

I'm trying to make all white pixels transparent using the Python Image Library. (I'm a C hacker trying to learn python so be gentle) I've got the conversion working (at least the pixel values look correct) but I can't figure out how to convert the list into a buffer to re-create the image. Here's the code img = Image.open('img.png') i...

Converting an ImageMagick FX operator to pure Python code with PIL

I'm trying to port some image processing functionality from an Image Magick command (using the Fx Special Effects Image Operator) to Python using PIL. My issue is that I'm not entirely understanding what this fx operator is doing: convert input.png gradient.png -fx "v.p{0,u*v.h}" output.png From a high level, this command takes the c...

HowTo put region of Pyglet image into PIL Image?

My app reads frames from video (using pyglet), extracts a 'strip' (i.e. region - full width by 1 to 6 video lines), then pastes each strip (appends it) into an image that can later be written out an *.png file. Problem is Pyglet GL images are stored in graphics memory, so are very limited re size. My current klunky workaround is build u...

Why in the world does Python's Tkinter break using canvas.create_image?

I've got a python GUI app in the workings, which I intend to use on both Windows and Mac. The documentation on Tkinter isn't the greatest, and google-fu has failed me. In short, I'm doing: c = Canvas( master=frame, width=settings.WINDOW_SIZE[0], height=settings.WINDOW_SIZE[1], background=settings.CANVAS_COLOUR ) file = ...

Python's PIL crop problem: color of cropped image screwed

Hi, I have a probably very basic problem with PIL's crop function: The cropped image's colors are totally screwed. Here's the code: >>> from PIL import Image >>> img = Image.open('football.jpg') >>> img <PIL.JpegImagePlugin.JpegImageFile instance at 0x00 >>> img.format 'JPEG' >>> img.mode 'RGB' >>> box = (120,190,400,415) >>> area = img...