Python and Reading Pixel Values.

My question is this: I am using Blender.Image to load an image. Is there a way of finding out the color values of a certain pixel? I don’t see it in the Image class.

Blender itself doesn’t give you this ability. However, there is a python library that you must download separately called PIL (Python Imaging Library). You can load the image using PIL and read the pixel values with that. The problem with going this route is that anyone wanting to run your script will need to have PIL as well. It is the only way to read pixel values, as far as I know, without writing the image code in python itself though.

I remember PIL works only on windows. But ImageMagick(http://www.imagemagick.com/) wrapper should run on linux and windows
http://www.procoders.net/pythonmagick is my choice among kings of wrapper.

PIL does work fine at least on Linux and Mac too, besides Windows, and probably on other platforms too. Does the job, as surely ImageMagick will too.

~Toni

Thanks for the replies.

I was able to get PIL for my mac and all is well and fine there.

It does kind of suck that other users must install PIL, but oh well, I suppose it’s just for me right now.

ok. PIL is not the worst dependency, 'cause it’s pretty nice to install and many other Python tools use it too (at least Soya3d and Skencil on my box. dunno if there are any widely popular though)

~Toni

The end user doesn’t necessarily need a full installation of PIL. All you need to do is include the dependant PILL pyc files in a zip with your script and it should work. Python is very flexible like that.