I need to replace all white (ish) pixels in an PNG image with alpha transparency.
I use Python in AppEngine and therefore do not have access to libraries like PIL, imagemagick, etc. AppEngine has an image library, but it breaks down mainly into image resizing.
I found a great little pyPNG module and managed to bring down a little function that does what I need:
make_transparent.py
The pseudocode for the main loop will look something like this:
for each pixel:
if pixel looks "quite white":
set pixel values to transparent
otherwise:
keep existing pixel values
and (considering 8-bit values) "pretty white" will be:
where each r,g,b value is greater than "240"
AND each r,g,b value is within "20" of each other
, , , . , ? (?)
, - / .
!