MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Transparent background with PNG

  • To: mathgroup at smc.vnet.net
  • Subject: [mg96920] Re: Transparent background with PNG
  • From: Stonewall Ballard <stoneyb at gmail.com>
  • Date: Fri, 27 Feb 2009 06:13:24 -0500 (EST)
  • References: <gnm1o0$hgg$1@smc.vnet.net>

On Feb 20, 5:47 am, replicator... at gmail.com wrote:
> Hi,
>
> how can I save an image to PNG format (eg. a simple plot), with the
> (white) background being transparent? I understand that PNG export
> supports alpha channel, but have no clue how to instruct Mathematica
> to exploit it.

This seems to be excessively obscure, but I got a png with a
transparent background this way (in V7):

plotImage = Plot[x^2, {x, 0, 2}]

bkgImage =
 Image[ConstantArray[{0., 0., 0., 0.},
   Reverse[ImageDimensions[plotImage]]], ColorSpace -> "RGB"]

compImage = ImageCompose[bkgImage, plotImage]

Export["~/Desktop/compImage.png", compImage]

It seems that composing the graphic against a transparent image gives
it an alpha channel.


  • Prev by Date: Re: Bug in Export to HTML in v7?
  • Next by Date: Re: About Reduce and Mod
  • Previous by thread: Re: Transparent background with PNG
  • Next by thread: Re: Transparent background with PNG