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.

7275 questions
3
votes
3 answers

how to use ImageQt

I would like to use ImageQT so I can do image manipulation with the Python Image Library (PIL) and render the result using Qt4. I have a short test routine that reads the using PIL.Image.open, converts it using ImageQT and opens a dialog using QT. …
steven smith
  • 1,309
  • 12
  • 27
3
votes
1 answer

How to transfer images to client using Python BaseHttpRequestHandler in Windows?

I know that this question has already been asked before, for instance here: How do I serve image Content-types with Python BaseHTTPServerRequestHandler do_GET method?, but the typical answer of "set your file open mode to binary" is not working for…
RTF
  • 5,332
  • 8
  • 47
  • 104
3
votes
2 answers

Loading image from Flask's request.files attribute into PIL Image

image = Image.open(request.files["fullimage"]) returns: IOError: cannot identify image file and image = Image.open(request.files["fullimage"].read()) returns: IOError: [Errno 22] invalid mode ('rb') or filename: '' What's the right way to do…
matthewk
  • 1,771
  • 15
  • 30
3
votes
1 answer

Creating simply image gallery in Python, Tkinter & PIL

So, I'm on simple project for a online course to make an image gallery using python. The thing is to create 3 buttons one Next, Previous and Quit. So far the quit button works and the next loads a new image but in a different window, I'm quite new…
SterlinkArcher
  • 591
  • 2
  • 18
  • 32
3
votes
1 answer

In-memory thumbnail generation in python

I store uploaded images in gridfs (mongodb). Therefore, the image data is never saved on the normal filesystem. This works by using the following code: import pymongo import gridfs conn = pymongo.Connection() db = conn.my_gridfs_db fs =…
Alp
  • 27,423
  • 26
  • 110
  • 190
3
votes
1 answer

Python PIL: verify extension before saving

Is there a way to check whether an extension is okay for PIL before attempting to save an image? In the example below, if ext = "jpg" then it works fine, but if it's "xxx" then I get a keyError. my_image.save(filepath + ext)
user984003
  • 23,717
  • 51
  • 158
  • 250
3
votes
1 answer

PIL png resize to smaller resolution makes file size bigger

I'm resizing .png files with python's PIL. For some reason the file size is 3x times bigger than the original, even though I the resolution got reduced. So how do I save the file correctly? Test1: png(6kb, 200x200) >> png(17kb, 100x100) <-- the one…
krivar
  • 312
  • 1
  • 3
  • 15
3
votes
2 answers

Python3 PIL (Pillow) draw.pieslice bad arc

I'm dawing a simple pieslice with PIL image = Image.new("RGBA", (256, 128), "#DDD") draw = ImageDraw.Draw(image, image.mode) draw.pieslice((0, 0 , 64, 64), 180, 270, fill="white) del draw image.save("file.png", "PNG") As you can see the arc is…
rkmax
  • 15,852
  • 22
  • 82
  • 170
3
votes
5 answers

Error Installing PIL using pip

I am Trying to install PIL using pip using the command: pip install PIL but i am getting the following error and i have no idea what it means. Could someone please help me out. nishant@nishant-Inspiron-1545:~$ pip install PIL Requirement already…
nish
  • 6,230
  • 17
  • 60
  • 113
3
votes
1 answer

Python - How to save a list as an image?

I generate a regular list. Is it possible to save this list as a JPEG image or PNG or whatever so that I can open the image and look at it? I am currently trying to figure it out using the python imaging library (PIL).
3
votes
0 answers

Python barcode library Error

I have installed pybarcode0.6 lib in Windows 7. After installing it, I had written the following code to generate the barcode for my module: import barcode from barcode.writer import ImageWriter import base64 EAN =…
3
votes
1 answer

Loading a blob(Google app Engine) into PIL or NumPy

I'd like to be able to load a blob(image into the Python Image Processing Library or into a numpy array for analysis(such as mean, median, standard deviation) without using the serving url. Here is my image database the t_image_url contains the…
piyushg91
  • 111
  • 1
  • 13
3
votes
2 answers

Adding a transparent circle to an image on python with PIL

I have a python program that craetes a png file with a circle on it. Now I want this circle to be semi transparent, given an alpha value. Here is what I do: img_map = Image.new(some arguments here) tile = Image.open('tile.png') img_map.paste(tile,…
otmezger
  • 9,027
  • 17
  • 55
  • 84
3
votes
1 answer

ImportError: The _imaging C module is not installed? PIL Python3

root@syscomp1:~# cd Pillow-master root@syscomp1:~/Pillow-master# python3 selftest.py Traceback (most recent call last): File "selftest.py", line 8, in from PIL import Image File "./PIL/Image.py", line 155, in if…
John Walker
  • 1,097
  • 4
  • 24
  • 64
3
votes
3 answers

View a sequence of images using Python and NumPy

I am using python's pil library to display images. Now I have a sequence of frames to display as a video content. I have a np.array that contains the RGB values of all the frames. Could not find a method similar to Mathlabs implay to display these…
change
  • 2,530
  • 6
  • 28
  • 40