Recently I downloaded some flags from the CIA world factbook. Now I want to "classify them.
Get the colors
Get some shapes (stars, moons etc.)
While browsing I came across the Python Image Library which allows me to extract the colors (i.e. for Austria:
#!/usr/bin/env python
import Image
bild = Image.open("au-lgflag.gif").convert("R...
This question is somewhat language-agnostic, but my tool of choice happens to be a numpy array.
What I am doing is taking the difference of two images via PIL:
img = ImageChops.difference(img1, img2)
And I want to find the rectangular regions that contain changes from one picture to another. Of course there's the built in .getbbox() ...
How do I use PIL to implement the equivalent of merging a layer in "dodge" mode with another layer (as done in Gimp/Photoshop)?
I have my original image as well as the image I'd like to use as the layer to merge with, but I don't how to do the dodge merge/composite:
from PIL import Image, ImageFilter, ImageOps
img = Image.open(fname)
...
I'm trying to create a .exe from a python program using py2exe, but when I run the .exe I get a log file with
Exception in thread Thread-1:
Traceback (most recent call last):
File "threading.pyc", line 532, in __bootstrap_inner
File "threading.pyc", line 484, in run
File "webcam.py", line 66, in loop
File "ImageStat.pyc", line 5...
Hi, I'm writing a simple application in Python which displays images.I need to implement Zoom In and Zoom Out by scaling the image.
I think the Image.transform method will be able to do this, but I'm not sure how to use it, since it's asking for an affine matrix or something like that :P
Here's the quote from the docs:
im.transform...
I have two images, both with alpha channels. I want to put one image over the other, resulting in a new image with an alpha channel, just as would occur if they were rendered in layers. I would like to do this with the Python Imaging Library, but recommendations in other systems would be fantastic, even the raw math would be a boon; I ...
Hi all,
I've been struggling with this error for several days with little headway. Basically, I'm trying to read in an image file and then use PIL to preform a specific operation on it. (my end goal is to preform a PIL paste operation).
However, whenever I load my image in, and then invoke the load() method on it (operations like s...
I have a raw image where each pixel corresponds to a 16 bits unsigned integer. I am trying to read using the PIL Image.fromstring() function as in the following code:
if __name__ == "__main__":
if (len(sys.argv) != 4):
print 'Error: missing input argument'
sys.exit()
file = open(sys.argv[1], 'rb')
rawData = ...
Hi all,
I've been looking for a way to download an image from a URL, preform some image manipulations (resize) actions on it, and then save it to a django ImageField. Using the two great posts (linked below), I have been able to download and save an image to an ImageField. However, I've been having some trouble manipulating the file ...
I have a model that has an option photo field. When a photo is added, I want a thumbnail to be automatically created and stored. However, when I do this with a pre_save signal, I keep getting an IOError, and if I try to do it with a post_save signal I can't save the thumbnails path to my model without creating and infinite post_save loop...
My question is similar to here, I would like to be able to swap out an image on a Tkinter label, but I'm not sure how to do it, except for replacing the widget itself.
Currently, I can display and image like so:
import Tkinter as tk
import ImageTk
root = tk.Tk()
img = ImageTk.PhotoImage(Image.open(path))
panel = tk.Label(root, image =...
I'm trying to figure out how to extract a given frame from an animated-gif, possibly in PIL, in Python.
I'm not able to easily dig this up, and I'm guessing it would take some knowledge of the gif format, something that is not readily understandable to me.
Is there any straightforward way to accomplish this? Do I need to do some custom p...
Hi, I want to do some image processing using Python - is there a simple way to import .png image files as a matrix of greyscale/RGB values (possibly using PIL)?
...
I have a view in my Django application that automatically creates an image using the PIL, stores it in the Nginx media server, and returns a html template with a img tag pointing to it's url.
This works fine, but I notice an issue. For every 5 times I access this view, in 1 of them the image doesn't render.
I did some investigation and...
Hey guys, I have a png file generated by Gnuplot that I need to put into an excel document using XLWT.
XLWT can't import PNG's into the document, only BMP's, so I needed to convert the PNG first. I used PIL for this.
Here's the relevant code:
im = Image.open('%s' % os.path.join(os.getcwd(), s + '.png'))
im.save('%s.bmp' % s)
However...
I am on Mac, Snow Lepard.
In preparation to install PIL I need to install libjpeg.
So, from my home directory I did:
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config/config.sub .
cp /usr/share/libtool/config/config.guess .
./configure --enable-shared --enable-static
make
sudo make install
But actually I read later...
I am getting the:
IOError: decoder zip not available
when I try to draw an image and save to a jpeg in PIL. Any thoughts on how to resolve this?
PIL has worked fine for me in the past, when it comes to viewing/uploading images.
...
Hi,
I want to be able to use the PIL library on a web hosting machine. The machine has Python 2.4.3 installed, but not the PIL library. I tried downloading the PIL source and putting the PIL folder into my directory. It kind of works, except when I need to do some actual image processing, which brings up an ImportError, saying that "The...
srcImage.paste(letters['H'], (10,15))
The above code will paste the letter H on the image (srcimage). letters is dict which contains the font images..
I cannot use paste in my assignment but i can use getpixel, load, putpixel, and save.
I tried this but this is giving error:
srcImage.putpixel((10,15),letters['H'])
Error is:
File "C:\...
I set up a VirtualBox to use two monitors. I tried taking a screenshot of a window on the second monitor:
import ImageGrab
im = ImageGrab.grab(windowrect)
im.save("img.png")
windowrect I verified to be the correct rect of the window, in this case, (1616, 2, 2594, 732). However, img.png is just a big black box. Any ideas how to fix thi...