Quite a cryptic title, but if you haven’t guessed, were talking about Images. This being a Python article that’s what we're using! If you’ve never thought about it, or -- even better -- if you didn’t know it was possible then you’re in for a nice surprise; not only can Python do this but it’s pretty good at it, too. Actually, Python works well with graphics in general, but for now we’re sticking to the 2D kind.
Why would anyone want to do this with a language like Python?
Fortunately this is not a question I've had to ask myself since the answer seems pretty obvious to me. But basically that's what this article is all about. Over the next few pages we'll be looking at some of the different places you could use Python to automate and generally play with your images.
You will need to have at least basic knowledge of these subjects, so if you're new to Python you should probably read Vikram Vaswani's "Python 101" first and come back later!
Essentially when you do anything to an image what you're actually doing is writing/moving bytes around. You can do this manually, but when you have an excellent third party module like PIL (Python Imaging Library), why bother?
So let's add a little extra image processing power to Python! You can get the latest version of PIL from www.pythonware.com
Windows users should download the windows installer (.exe). Those installing PIL from source should probably take a look through "Installing Python Modules" in the Python docs, if only out of interest.
On to the Fun Stuff
Ok, now that we have the "basics" out of the way, it's time for the fun stuff! Something like converting a JPEG image to a GIF maybe. In most cases all you should have to do is open the image and save it with a different file extension and PIL will do the rest!