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] transparency in palette mode ( "P" ) images
by Ivan Mincik other posts by this author
Oct 19 2009 2:09PM messages near this date
[Image-SIG] transparency in palette mode ( "P" ) images | Re: [Image-SIG] transparency in palette mode ( "P" ) images
Dear list,
I have PNG image in  palette mode, with 256 color palette. Every color
has different level of transparency.
For example:
  Color Table (RGB with 256 entries)
    0: 0,0,0,0
    1: 238,238,238,154
    2: 253,253,109,154
    3: 0,0,0,2
    4: 0,0,0,4
    5: 0,0,0,8
    6: 0,0,0,6
    7: 237,237,237,154
    8: 0,0,0,14
    9: 35,35,15,153
   10: 1,1,0,138

I am trying just to open and save this image using PIL.
#!/usr/bin/python
import Image

im = Image.open('test.png')
im.save('out.png', transparency=0 )

After running this code, the resulting image is loosing transparency
information for each color and it is set to 255.
 Color Table (RGB with 256 entries)
    0: 0,0,0,0
    1: 238,238,238,255
    2: 253,253,109,255
    3: 0,0,0,255
    4: 0,0,0,255
    5: 0,0,0,255
    6: 0,0,0,255
    7: 237,237,237,255
    8: 0,0,0,255
    9: 35,35,15,255
   10: 1,1,0,255

Is there any way how to save the image with exactly same palette as
original image ?

For anybody wanting to look at this problem, You can download my test
image here:
http://gista.sk/dl/test.png

Thanks,
Ivan
_______________________________________________
Image-SIG maillist  -  Image-SIG@[...].org
http://mail.python.org/mailman/listinfo/image-sig
Thread:
Ivan Mincik
Ivan Mincik
Laura & Edward Cannon
Ivan Mincik
Ivan Mincik
David Kwast

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved