[Image-SIG] PIL Convert Alpha-transparent image to non-transparent?
chander.ganesan at gmail.com
Mon Jul 5 17:54:09 CEST 2010
I've done quite a bit of searching on Google for this and have yet to
find a working result, so hopefully someone here will know...
I've got an image that has alpha transparency, it has a non-white
background color (that is transparent), and several pixels are
"partially" transparent. If I take the image and convert it over from
RGBA to RGB, the text in the image looks "blocky".
I need to convert the image to a non-transparent one (so I can pass it
into tesseract for OCR) but I cannot seem to do so without loosing
quality of the text in the image. Is there a standard way to do this?
I've tried the following (all to no avail):
- Iterate over the pixels and find those that are more than 50%
transparent and convert them to white (ends up with a dithered image)
- Use Paste onto a white background that has no transparency, and then
convert to RGB (no luck there)
- Use Image.blend to attempt to blend with a white background (at
various levels), no luck there.
Any help - or pointers in the right direction - would be much appreciated!
More information about the Image-SIG