ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> image-sig
image-sig
[Image-SIG] Re: gimp-2.0 palette
by Fredrik Lundh other posts by this author
Sep 7 2004 11:52AM messages near this date
[Image-SIG] gimp-2.0 palette | [Image-SIG] Problems with XpmImagePlugin.py
colliera@[...].za wrote:

>  has anyone tried to import gimp-2 palettes using the GimpPaletteFile
>  module?
>  i don't imagine that it would be too difficult to cater for both?

I've attached a patch.

</F> 

Index: PIL/GimpPaletteFile.py
===================================================================
--- PIL/GimpPaletteFile.py (revision 1969)
+++ PIL/GimpPaletteFile.py (working copy)
@@ -20,1 +20,1 @@

-import string
+import re, string

 ##
 # File handler for GIMP's palette format.
@@ -37,13 +38,13 @@

             if not s:
                 break
+            # skip fields and comment lines
+            if re.match("\w+:|#", s):
+                continue
             if len(s) >  100:
                 raise SyntaxError, "bad palette file"

-            if s[0] == "#":
-                continue
-
-            v = tuple(map(string.atoi, string.split(s)[:3]))
+            v = tuple(map(int, string.split(s)[:3]))
             if len(v) != 3:
                 raise ValueError, "bad palette entry"



_______________________________________________
Image-SIG maillist  -  Image-SIG@[...].org
http://mail.python.org/mailman/listinfo/image-sig
Thread:

Fredrik Lundh

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved