|
I don’t think I need support… unless I am doing
something wrong here J Please direct me: I have a script that converts a 32 bit RGBA image over to
another 32 bit RGBA image, but in the middle, it reduces the number of colors
for each plane. This allows for pre-dithering when outputting to 15 and 16 bit
displays. The bug I have noticed is that the values get shifted during
the “quantize” function, even when using a pure linear palette. I
discovered this when I fed in an image that had an input alpha value of 255 and
it came back out at 252. Here is the script: def RGBADither(bands_colors = [32.0,64.0,32.0,256.0],
input_file="", output_file=""): import
Image, ImagePalette im
= Image.open(input_file) bands
= im.split() outbands=
[0,0,0,0] for
band in range(len(bands)): data = ""> for
i in range(256): v
= chr(int((int((i/256.0)*bands_colors[band])/bands_colors[band])*256.0)) data
+= chr(v) + chr(v) + chr(v) p
= ImagePalette.raw("RGB", data) pimage
= Image.new("P", (1, 1)) pimage.palette
= p tmp
= bands[band] tmp
= tmp.convert(mode="RGB") tmp
= tmp.quantize(palette=pimage) tmp
= tmp.convert(mode="L") outbands[band]
= tmp tmp.save("band%s.png"%band) out
= Image.merge("RGBA", outbands) out.save(output_file) |
_______________________________________________ Image-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/image-sig
