On Thu, Aug 12, 2010 at 1:56 AM, Miha Tomšič <miha.tom...@gmail.com> wrote:

> Hello!
>
> I am having trouble saving figures to PNG with Agg backend. The problem is
> I can't get a PNG without transparency even if I specify:
>
> fig.savefig("colorAgg.png", dpi=300, transparent=False)
>
> identify still indicates there is a 1-bit aplha channel present:
>
> Image: colorAgg.png
>  Format: PNG (Portable Network Graphics)
>   Class: DirectClass
>  Geometry: 390x300+0+0
>   Resolution: 118.11x118.11
>  Print size: 3.30201x2.54001
>   Units: PixelsPerCentimeter
>  Type: TrueColorMatte
>   Endianess: Undefined
>  Colorspace: RGB
>   Depth: 8-bit
>  Channel depth:
>     red: 8-bit
>    green: 8-bit
>     blue: 8-bit
>    alpha: 1-bit
>   Channel statistics:
>    red:
>       min: 0 (0)
>      max: 255 (1)
>       mean: 192.918 (0.756542)
>      standard deviation: 96.4001 (0.37804)
>     green:
>      min: 0 (0)
>       max: 255 (1)
>      mean: 189.457 (0.74297)
>       standard deviation: 98.0884 (0.38466)
>    blue:
>       min: 0 (0)
>      max: 255 (1)
>       mean: 177.814 (0.697309)
>      standard deviation: 107.593 (0.421932)
>     opacity:
>      min: 0 (0)
>       max: 0 (0)
>      mean: 0 (0)
>       standard deviation: 0 (0)
>  Histogram:
>      75477: (255,255,255,  0) #FFFFFF white
>      8184: (  9,106, 37,  0) #096A25 rgb(9,106,37)
>       8119: (113,170, 76,  0) #71AA4C rgb(113,170,76)
>      8119: (204,  0,  0,  0) #CC0000 rgb(204,0,0)
>       6655: (  0,  0,  0,  0) #000000 black
>      3466: (  1,  1,  1,  0) #010101 rgb(1,1,1)
>       2482: (106,106,106,  0) #6A6A6A rgb(106,106,106)
>       287: (  3, 44, 15,  0) #032C0F rgb(3,44,15)
>        285: ( 47, 71, 31,  0) #2F471F rgb(47,71,31)
>       285: ( 85,  0,  0,  0) #550000 rgb(85,0,0)
>        215: (  2,  2,  2,  0) #020202 rgb(2,2,2)
>       196: (116,116,116,  0) #747474 rgb(116,116,116)
> ...
> ----------------------------------------------------------------
>
> This is not a big deal but there si a problem when I insert this PNGs in
> PDF and there si a RGB/CMYK conversion on every page that contains
> transparent PNG.
>
> How can I get rid of the aplha channel completely? How do I tell the
> backend to work (or at least save) in pure RGB not in RGBA color space?
>
> Thanks and take care,
> Miha
>
>
>
Miha,

The documentation states that the 'transparent' kwarg controls whether the
background of the figure and the axes will be transparent.  It does not
control the transparency of the figure elements.

I dug a little further and also found that the code that writes PNG files
can only save in RGBA mode and has no capability of writing in RGB mode.  It
might be "possible", but it certainly isn't doable through a function
argument. New code will have to be written.

If you would like, you can file a feature request for this at
http://sourceforge.net/tracker/?group_id=80706

In the meantime, I believe it is possible to use ImageMagick:

*convert img-rgba.png -flatten img-rgb.png*

I hope that helps.
Ben Root
------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to