I ask this question a lot (by imgscalr) - the problem is almost always that you read / write different file formats, and the ALPHA channel causes one of your color channels (R / G / B) to be selected from the resulting file.
For example, if you read in an ARGB file (4 channels) and write it as JPG (3 channels) - if you do not purposefully manipulate the image types themselves and render the old image directly, you will get a file with "ARG" channels ... or, more specifically, only red and green are blue.
PNG supports the alpha channel, and JPG does not, so keep that in mind.
To fix this, you need to purposefully create the appropriate BufferedImage of the desired type (RGB, ARGB, etc.) and use the call destImage.getGraphics() to render one image to another before writing it to disk and transcoding it.
Sun and Oracle NEVER made ImageIO libraries smart enough to detect unsupported channels when writing to different file types, so this behavior happens all the time :(
Hope this helps!
source share