blogs tagged "python"

PIL -> Pillow?

Mon Nov 17 2014 07:05:54 GMT-0800 (Pacific Standard Time)

tags: python code software

I was pleased to learn that the Python Imaging Library (PIL) has a modernized fork called Pillow. From the Pillow site:

The fork authors’ goal is to foster active development of PIL through:

This is great news for me, because there are several projects (this site included) that use PIL, and I have been worried about its future. In addition to the infrequent PIL releases, the lack of Python 3 support in PIL was starting to be a real drag...and it was the main thing that kept some of us on Python 2.7.

So yeah, it's nice to have a path forward...time to embrace the fork and move on. I will miss the PIL acronym.

Learning Python by building image-pooping Markov chains

Fri Dec 19 2008 23:41:05 GMT-0800 (Pacific Standard Time)

tags: python programming markov

In my ongoing attempt to learn yet another utilitarian programming language, I have decided to pick up some Python. I'm only still scratching the surface (for example I haven't even touched python regular expressions yet, nor object persistence/marshalling), but I've managed to make a few toys. I often learn best by just diving in and doing, and I've come to enjoy stumbling through toy projects when learning a new language.

So I thought it would be interesting to see what kind of images I could create with a self-modifying, mutative Markov chain. While the results below aren't yet self-modifying, they're somewhat entertaining eye-candy that's probably been done hundreds of times before.

![image]( 9_th.png) ![image]( 9_th.png) ![image]( 1_th.png) ![image]( 4_th.png) ![image]( 5_th.png) ![image]( 1_th.png) ![image]( 8_th.png) ![image]( 5_th.png) ![image]( 0_th.png) ![image]( 5_th.png) ![image]( 6_th.png) ![image]( 4_th.png) ![image]( 4_th.png) ![image]( 3_th.png) ![image]( 1_th.png) ![image]( 6_th.png) ![image]( 0_th.png) ![image]( 0_th.png) ![image]( 4_th.png) ![image]( 5_th.png) ![image]( 3_th.png) ![image]( 4_th.png)

I'm using the Python Imaging Lirbary (PIL) to create/paint the images. Sure, it's pretty well documented and intuitive, but doesn't immediatly support drawing with alpha transparency, which is a real bummer. There is at least one other drawing toolkit that does alpha, and one that does that with opengl. It would be nice to render these in realtime, but the current incantation seems to take about a second to do about 54k 2d polygons, which isn't exactly fast. I'm also not yet sure how much of that time is spent in python versus actual Tk rendering.

I'm now mostly interested in switching drawing toolkits to support alpha, doing marshalling to save/restore interesting chains, and coming up with interesting strategies of self-modification. The current models are very linear, and it might be nice to have a little abstraction that allows nonlinear curving to happen more seamlessly.

I'll probably share the code after I continue to learn from my mistakes and make things more better.