views:

386

answers:

1

All i need is create a .png image with transparent background, draw some text in black on it and save it using img.save('target.png', option='optimize')

It looks like to save .png images in 32-bit mode automatically. Can I reduce the color depth while not make the output images looks much worse before saving? Since it contains only black text and transparent background, i guess reducing color depth would greatly reduce file size.

+1  A: 

Hey jack, check this answered question about PIL color depth. :)

Pedro Ghilardi
thanks, img.convert('LA') do some optimization but not that much as I expected (lower compression rate than optipng). img.convert('P') just turns whole image to black.
jack
Try `img.convert('P', colors= n, palette=Image.ADAPTIVE)`.
bobince