I’m trying to convert a gif to a jpeg using imageIO but the resulting image is pink… Anyone can help?
public byte[] convert(byte[] bytes)
throws Exception {
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
BufferedImage bufferedImage = ImageIO.read(inputStream);
ByteArrayOutputStream osByteArray = new ByteArrayOutputStream();
ImageOutputStream outputStream = ImageIO.createImageOutputStream(osByteArray);
ImageIO.write(bufferedImage, "jpg", outputStream);
outputStream.flush();
outputStream.close();
return osByteArray.toByteArray();
}
Perhaps, pink is defined as the transparency color for the gif image. If so, the following example might work. Basically, a new image is created and the “backgound color” is explicitly set to whatever is passed in.
Looks like this might be related.