I have a java application that receives image files. I want to rotate them using the exif information.
Here on StackOverflow, i found two different approaches, in both cases I start with an BufferedImage:
BufferedImage image=ImageIO.read(sourceFile.getInputStream());
The first solution is coming from this post.
ImageTransformer.ImageInformation imageInformation=ImageTransformer.readImageInformation(sourceFile.getInputStream());
AffineTransform tranform=ImageTransformer.getExifTransformation(imageInformation);
image=ImageTransformer.transformImage(image,tranform);
The second one was also recommended in some post here, using Thumbnailator:
BufferedImage image = Thumbnails.of(sourceFile.getInputStream()).scale(1).asBufferedImage();
Both ways do properly rotate my image. But also both solutions change the coloring, which i do not want. I will attache two files, the "white" one is the original file with wrong rotation. This is exactly what I achieve when I comment out both rotation codes.
The other, the red one, is the one with proper rotation, but wrong color.
How can I have the original color with just changing the rotation?