Closed dmitry-weirdo closed 3 years ago
Looks like it's working for File
and InputStream
, but not working for BufferedImage
of this file.
BufferedImage bufferedImage = ImageIO.read(imageFile);
InputStream inputStream = new FileInputStream(imageFile);
// NOT rotated!
Thumbnails.of(inputStream)
.width(width)
.outputFormat("jpg")
.toFile("c:\\java\\thumbnail-input-stream.jpg");
// NOT rotated!
Thumbnails.of(imageFile)
.width(width)
.outputFormat("jpg")
.toFile("c:\\java\\thumbnail-image-file.jpg");
// Rotated :(
Thumbnails.of(bufferedImage)
.width(width)
.outputFormat("jpg")
.toFile("c:\\java\\thumbnail-buffered-image.jpg");
@dmitry-weirdo, Exif is metadata that's stored in certain image files. A BufferedImage
does not contain Exif information. If you want to use Exif-based rotation, you will need to use either the File
or InputStream
as the input.
I'm closing this issue as it is expected behavior. Please refer to my previous comment for why rotation based on Exif won't work in the code you originally posted.
IT is also happening when i work with FIle aswell,
Thumbnails.of(targetLocation.toFile()) .useExifOrientation(true) .size(320, 320) .keepAspectRatio(true) .outputFormat("jpg") .toFiles(Rename.PREFIX_DOT_THUMBNAIL); response.setThumbnailPath("thumbnail." + fileName);
Expected behavior
Image thumbnail is NOT rotated 90 degrees left.
Actual behavior
If image has height more than width, it is rotated 90 degrees left.
Whatever combinations of
size
,width
,useExifOrientation
,keepAspectRatio
I set, the thumbnail is rotated. Image size is also always the same.Code example:
Steps to reproduce the behavior
See the "Actual Behavior" section
Environment
OS vendor and version: Microsoft Windows [Version 10.0.17134.1667]
JDK vendor and version: java version "11.0.8" 2020-07-14 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.8+10-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)
Thumbnailator version: 0.4.12