Re: Manage PNG Transparency with ImageJ
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Dec 27, 2010; 9:49pm
URL: http://imagej.273.s1.nabble.com/Manage-PNG-Transparency-with-ImageJ-tp3685645p3685647.html
On Dec 27, 2010, at 12:06 PM, Charles Flond wrote:
> Hi All,
>
> Does anybody know how to manage PNG files with transparency using ImageJ ? I
> tried to use the function writeImageWithTransparency(ImagePlus imp, String
> path, int transparentIndex) but it doesn't seem to work.
>
> See
http://rsb.info.nih.gov/ij/source/ij/plugin/PNG_Writer.java for more
> details about this function.
>
> Any suggestions would be welcomed ! Thanks in advance.
Plugins and scripts can save an 8-bit image as a PNG with transparency using
imp = IJ.getImage();
Prefs.setTransparentIndex(index);
IJ.saveAs(imp, "PNG", file_path);
where 0<=index<=255. Macros can use
call("ij.Prefs.setTransparentIndex", index);
saveAs("PNG", file_path);
ImageJ does not support display with transparency so you will need to open the saved PNG in another application (e.g., a Web browser) to verify that the pixels with a value of 'index' are transparent. Note that PNG and GIF transparency only works with 8-bit images.
-wayne