coobird / thumbnailator

Thumbnailator - a thumbnail generation library for Java
MIT License
5.14k stars 785 forks source link

Automagically rotating image? #88

Closed sykesd closed 8 years ago

sykesd commented 8 years ago

I have a source image that is a JPG, 3264 wide x 2448 high. The image is a photo taken with the camera held sideways, i.e. the photo shows a scene vertically that is horizontal in real life.

I use the following code to create a thumbnail of the photo:

File folder = new File("/Photos");
Thumbnails.of(folder.listFiles())
    .size(200, 150)
    .outputFormat("png")
    .toFiles(Rename.PREFIX_DOT_THUMBNAIL);

The resulting thumbnail is of high quality, but with the scene rotated 90 degrees so that it is "correct". However, the resulting thumbnail is now actually not the requested size. It is in fact 150x200.

The use-case we are trying to implement is a simple photo viewer - the users sees a collection of thumbnails. Clicking on one shows the original image. We would like all of the thumbnails to have a consistent size. Also, it would be surprising for the user if the thumbnail shows the scene in a different orientation to the original.

Can the auto-rotation be suppressed? Would it be possible to detect the trigger conditions from the original image and then "correct" the original myself?

sykesd commented 8 years ago

RTFM

Just found the useExifOrientation() parameter.

Sorry about that.

dmitry-weirdo commented 3 years ago

For me, it rotates the image with both true and false values of useExifOrientation. Image is 2268x4032 JPG. I've created an issue here — https://github.com/coobird/thumbnailator/issues/159.