ImageJ resizing PNG with no transparency loss - how to
Posted by Martin Asenov on May 03, 2011; 10:27am
URL: http://imagej.273.s1.nabble.com/ImageJ-resizing-PNG-with-no-transparency-loss-how-to-tp3683481.html
Hi, guys,
Congratulations for the awesome framework - works fast and results in good
quality.
However, I tried to resize a PNG image with some transparency, and
unfortunately, the transparency got lost and replaced with the black color.
Here is my small snippet of code with which I do the resizing:
public BufferedImage resizeImage(BufferedImage image, int maxWidth) throws
IOException {
ImagePlus ip = new ImagePlus();
ip.setImage(image);
ImageProcessor imp = ip.getProcessor();
ImageProcessor imp2 = imp.resize(maxWidth);
ImagePlus ip2 = new ImagePlus("Resized Image", imp2);
return ip2.getBufferedImage();
}
It works great for JPEG, but when it comes to PNG transparency, it doesn't
do the thing I need. I was unable to find a work around in the ImageJ API.
Would you please assist?
Thanks a lot in advance!
Martin