[Image-SIG] Converting images to palette mode

Charlie Clark charlie at begeistert.org
Wed Jan 28 10:10:22 CET 2009

Am 28.01.2009 um 00:29 schrieb Gregor Kopka:

> also while looking at it i'm not that sure why you don't check the  
> extension by checking against a[-4:] == ".png" which i feel like a  
> bit more readable compared to your if condition.
> Do you want to stop your code from processing files with a "." in  
> the name (like 'mypic 02.05.2007.png') ?

Actually why not rely on os.path to identify things correctly in the  
first place?

Which book still recommends code like this?

if string.find(a,'.') > 0 and string.split(a,'.')[1]=='png' and  

Strings have had methods since Python 1.6!

But os.path.splitext() is probably all you need. Sorry that this won't  
help you find the cause of the crash.

Charlie Clark
Helmholtzstr. 20
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226

More information about the Image-SIG mailing list