[Image-SIG] Comparison of PIL and GD speed for setting pixels through python

John Barratt jb at langarson.com.au
Sun Feb 4 13:23:41 CET 2007

With prompting from Chris, and a little further work in gd, I have 
updated this comparison further, adding a further gd/ctypes test, this 
time setting pixel values using the raw pixel data, as well as the start 
of a test for a numpy/PIL option.  Unfortunately it doesn't fully work, 
at least with the version/s I have.  However it does, based on what does 
work, seem to be relatively slow.  The new indicative times look like this :

  Method          Time (s)        Times slower than fastest
+-----+         +-------+       +------------------------+
ctypes,c,GD raw 0.00082         1.0
ctypes,c,GD     0.00177         2.2
PIL - 'load'    0.03226         39.4
ctypes, GD      0.14428         176.4
PIL, numpy *    0.26271         321.2
PIL - 'point'   0.37180         454.5

Further details are here, including updated code :


I also fixed a few bugs that affected the image created, but not the 
timing, and added code to save the files out where possible to further 
check they were actually doing what was intended.



John Barratt - www.langarson.com.au
          Python, Zope, GIS, Weather

More information about the Image-SIG mailing list