This question already has an answer here:
I am using ImageIO.write() to convert PNG files to JPG. For some reason, my result image has a pink layer over it. I have searched far and wide for a solution but haven't found any. The code works for all other types of images except PNG.
Quick reading of other SO answers tagged ImageIO led to this.
The root cause can be a buggy reader. The proposed workaround is using different reader package.
Edit Above link is broken, but this appears to be it.
Edit The above links are broken, here it is on archive.org.
I'm not sure how the other code snippet works given buffer is not used after it's created. I've found this pink problem to be jvm version specific.
The easiest solution I've found is to do this.
I found this link which has some code that might be of use. I tried your code with a few of my images but I couldn't reproduce the issue. I tried the last answer by devyn_a and it didn't break anything. Here's your code modified with devyn_a's solution.
It would be interesting to know if this resolves the issue.
I too had the same problem, but if i write it in png format then it gets solved.
Something like this,