0

I´m using JAI to convert a tiff file into ajpeg file, but when the file is converted the colors are totally wrong. What´s wrong with my code? Is this a JAI Bug? When converting to PNG the file colors are working fine.

try {
    FileSeekableStream stream = null;
    stream = new FileSeekableStream(tiff);
    ImageDecoder dec = ImageCodec.createImageDecoder("tiff", stream, null);
    RenderedImage image = dec.decodeAsRenderedImage(0);
    JAI.create("filestore", image, output, "JPEG");
    return true;
} catch (IOException e) {
    e.printStackTrace();
    return false;
}

The output file:

enter image description here

The original file

enter image description here

takendarkk
  • 3,347
  • 8
  • 25
  • 37
Mister B
  • 123
  • 2
  • 15
  • Looks like your inverting the colors with the jpeg – Jason Jun 22 '18 at 20:48
  • Hi, How do this? – Mister B Jun 22 '18 at 20:56
  • I invert with online app, but not the original colors are applied. – Mister B Jun 22 '18 at 20:59
  • 1
    Be careful, ImageIO has a bug where writing a transparent image to a JPG causes issues in to the colors - see [Odd coloured JPEGs in Java with ImageIO](http://blog.idrsolutions.com/2009/04/odd-coloured-jpegs-in-java-with-imageio/) for more details – MadProgrammer Jun 22 '18 at 22:30
  • Possible duplicate [Pink/Reddish tint while resizing jpeg images using java thumbnailator or imgscalr](https://stackoverflow.com/questions/26115851/pink-reddish-tint-while-resizing-jpeg-images-using-java-thumbnailator-or-imgscal) and [java buffered image created with red mask](https://stackoverflow.com/questions/12963685/java-buffered-image-created-with-red-mask) – MadProgrammer Jun 22 '18 at 22:32

0 Answers0