Sunday, March 14, 2010

Python Image Library

Want to work on Images of any sort in python? The python image library is where it's at. You have to go and install it though.
I found out a couple less than straightforward things in doing this.
First, Python 3 and up don't have a version made for it yet. Yeah, one of those newer not being better things.

Second, if you plan on using it on the mac, like OsX I mean, you have to compile it yourself, which is quite intimidating for someone like me. Especially if yo have to dig around everywhere to find that OsX likes to run python in 64bit mode by default, even when you're on a 32 bit machine. So super fun. I had the same problem running an applescript from python.
Thirdly, and here's something I haven't figured out, is that it seems like on the mac, or in some configurations I have to either 'import PIL.Image' or 'import Image'.
to handle switching this easily, right now I'm doing 'import PIL.Image as Image' which is easiest to fix.

anyways, the documentation is quite easy to figure out, and then getting the size or data from the image is quite straightforward. Using composite with images that already have transparency saved me a billion hours now that I don't have to sit and watch Photoshop do it.

I thought I was having trouble with it today, but I was stupidly running my script with recursive directory image searching, so ended up saving over the output I was putting in a subfolder with a cropped copy of what I'd already put there. It got ugly and took forever to figure out.
So in respect to the last post talking about recursion:
recursion is a powerful ally, but also a dangerous enemy. Beware!

No comments:

Post a Comment