By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

PIL image.getcolors

P: n/a
I have an RGBA .png which PIL is able to read and I would like to convert the
image to a simple RGB image with a single colour reserved for transparent as the
A channel is either all on or all off.

I thought I could use the the im.getcolors method to find the colours used by
the image, but it sometimes returns None. Is there a smart way to find out an
unused colour or the least used colour in my image?

Additionally can PIL change a specified colour quickly. I'm guessing I might be
able to do it using the composite mechanism
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import Image
im0 ='trans.png')
[(55367, (255, 1, 25, 255)), (24104, (24, 79, 235, 255)), (46529, (0, 0, 0, 0))]
>>>im1 ='400px-Wiki_letter_w.svg.png')
im1.getcolors() is None

Robin Becker

Nov 29 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.