Questions tagged [python-imaging-library]

The Python Imaging Library (PIL) provides the Python language with a de-facto standard foundation for image work. PIL’s API is lightweight but semantically consistent; it furnishes a range of comfortably Pythonic tools throughout much of the imaging lexicon: processing, analysis, compression and codec abstraction, etc. – all of which builds upon a bespoke and readily extensible library structure.

The Python Imaging Library (PIL) provides the Python language with a de-facto standard foundation for image work.

PIL’s API is lightweight but semantically consistent. It furnishes a range of comfortably Pythonic tools, whose top-level hierarchy covers a broad lexical range of the imaging fields’ usual suspects, including: pixel and channel processing; statistical analysis; affine, Gaussian, and kernel transforms, abstraction for compressors, binary formats, codecs, and the like; vector drawing and typesetting; pixel mathematics and color correction; matrices; programming and I/O paradigms. Each of these is notionally organized into a Python sub-package and implemented with an API in a mode whose form is germane to its concept – e.g. while the IO modules like PIL.Image and PIL.ImageFile generally follow along with the Python standard libraries — they employ OO-style conventions that very similar throughout – PIL is not pedantic in this way, as other submodules are non-uniform when they need to be… PIL.ImageFilter, for example, is written in a functional style (obfuscated slightly, due to having been CamelCased). And PIL.ImageMath exposes its interface as a little subset of Python language itself, with which the programmer can tersely and legibly describe an algorithm – which PIL can then take and deterministically pipeline and vectorize into something much faster than naïve Python.However, it only supports Python 1.5.2 and newer, including 2.5 and 2.6.

More information can be found at PIL (PythonWare.com); founded and first developed by Fredrik Lundh, the original PIL codebase is open source, but unmaintained since 2011.

There is also an active, maintained and popular fork of PIL called Pillow which releases quarterly with security updates, new features and bug fixes, it supports python 3.x.

9873 questions
4
votes
1 answer

Cropping and displaying images using PIL and Tkinter

I am beginning to learn Python after being trapped using VB6 forever. To help myself learn some gui with Tkinter, I'm making a simple slot machine. To animate the wheels, I have a ~300x2000 image that has all of the pictures I intend to use…
4
votes
2 answers

Write Text to Image with Max Width in Pixels Python PIL

There is a similar question to mine here: python PIL draw multiline text on image However, the solution uses: textwrap.wrap(..., width=40) Which is the width in characters. I'm trying to do something where the width should be in pixels and all the…
user1387717
  • 1,039
  • 1
  • 13
  • 30
4
votes
1 answer

Alternative Python imaging libraries on Google App Engine?

I am thinking about uploading images to Google App Engine, but I need to brighten parts of the image. I am not sure if the App Engine imagine API will be sufficient. I consider to try an overlay with a white image and partial opacity. However, if…
Björn
  • 1,183
  • 2
  • 13
  • 18
4
votes
1 answer

can the python PIL deal with raw image data?

I have an raw image file that is .bin and is composed of 16 bits unsigned intergers. Can the python imaging library take this type of file and process it? My code is not running properly and giving me an invalid file type error but I think it may…
clifgray
  • 4,313
  • 11
  • 67
  • 116
4
votes
2 answers

Best way to programmatically create image

I'm looking for a way to create a graphics file (I don't really mind the file type, as they are easily converted). The input would be the desired resolution, and a list of pixels and colors (x, y, RGB color). Is there a convenient python library for…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
4
votes
1 answer

Blurring images containing text using Python Imaging Library

I have an image containing some text (in a standard document font-size) and I am trying to blur the image so that the text is no longer readable. However the default ImageFilter.BLUR in PIL is too strong, so the image is just blanked out save for a…
Erik Honn
  • 7,576
  • 5
  • 33
  • 42
4
votes
4 answers

How can I read a binary file and turn the data into an image?

Basically what I want to do is take a file, bring its binary data(decimal of course) into an list and then generate a grayscale bitmap image using PIL based on that list. For example if the file is 5000 bytes (image size will be 100 x 50) and each…
Hussien Hussien
  • 150
  • 1
  • 3
  • 14
4
votes
2 answers

Django says all Images invalid, but PIL works

I'm running a new Linode on Ubuntu 12.04 with Nginx, Gunicorn, and Django 1.4. Uploading to an imagefield (which works locally) claims the file is corrupt or invalid, including for images that work locally. PIL works. I can load, check, and collect…
4
votes
4 answers

Finding a specific index in a binary image in linear time?

I've got a 640x480 binary image (0s and 255s). There is a single white blob in the image (nearly circular) and I want to find the centroid of the blob (it's always convex). Essentially, what we're dealing with is a 2D boolean matrix. I'd like the…
4
votes
1 answer

Simple Image Metrics with PIL

I want to process uploaded photos with PIL and determine some "soft" image metrics like: is the image contrastful or dull? colorful or monochrome? bright or dark? is the image warm or cold (regarding light temperature)? is there a dominant…
fbuchinger
  • 4,494
  • 2
  • 30
  • 31
4
votes
2 answers

Can not pip install PIL in a virtualenv in Windows because of Warning and ValueError

I am trying to install PIL in a virtualenv but have failed. I created a brand new virtualenv and did pip install PIL and got the following C:\Users\s3z\Desktop\My Dropbox\pythons\ham>Scripts\activate (ham) C:\Users\s3z\Desktop\My…
user883807
4
votes
1 answer

Tkinter image display (with [converted] NumPy array)

In short, I'd like to convert a ImageTk.PhotoImage object to either a Image (PIL) object or numpy array. Knowing that you can convert a Image (PIL) object to a numpy array with numpy.asarray(). I'm given a numpy array and can display it in Tkinter…
Ryan
  • 129
  • 2
  • 8
3
votes
3 answers

How to install PIL with ZIP, JPEG, etc. on Ubuntu 11.10

I am trying to be able to import png, which I believe is from the PIL. I would also prefer if JPEG and the others were also working I am running Ubuntu 11.10. now from…
cah
  • 149
  • 3
  • 10
3
votes
1 answer

Using PIL to analyze a video frame by frame

I'm working on using PIL to average the pixel intensities over a subarea of a video. What I want to do is: -Use ffmpeg to turn the video into several frames -Use PIL to choose a window in each frame (this is the step I'd like help with) -Do some…
nathan lachenmyer
  • 5,298
  • 8
  • 36
  • 57
3
votes
1 answer

Using python and PIL how can I grab a block of text in an image?

I have an image (*.png) which contains two blocks of text. I am trying to grab each block of text individually using the python imaging library (PIL) in python27. I have tried to blur the image and then find the edges of the blurred block so that I…
user714852
  • 2,054
  • 4
  • 30
  • 52