haraldk / TwelveMonkeys

TwelveMonkeys ImageIO: Additional plug-ins and extensions for Java's ImageIO
https://haraldk.github.io/TwelveMonkeys/
BSD 3-Clause "New" or "Revised" License
1.87k stars 310 forks source link

Support automatic JPEG rotation according to Exif data #288

Open jforjava1981 opened 7 years ago

jforjava1981 commented 7 years ago

Would love to see this feature implemented as most of phone and digi cams use exif to indicate rotation and not all browsers support image-rotation css property to read exif and rotate it accordingly. It becomes a pain for a website like I am working on where users upload photos using digicams and photos and we have to take extra unnecessary steps to honour the exif while showing it.

I see a todo as well in JPEG reader. Hope it gets removed soon :)

haraldk commented 7 years ago

Thanks for putting it on the list!

Might happen some day. :-)

See this Stack Overflow question for background.

Best regards,

Harald K

Schmidor commented 7 years ago

I propose that if automatic rotation is implemented, it should be a feature which is deactivated as default. For simple image reading automatic rotation is not a problem. But on more complex scenarios, when metadata is handled explicitly, this at least affects width and height, which then differ from the read image. At least in my case I want to read the image as stored and handle such things myself where needed.

And to promote it: For 3.3 I've added some utility methods in the contrib-module, which already help with image orientation. :-) BufferedImage com.twelvemonkeys.contrib.tiff.TIFFUtilities.applyOrientation(BufferedImage input, int orientation)

haraldk commented 7 years ago

@Schmidor Good point promoting the utility method! 😀

Of course, should this be implemented, we also need to take orientation into account for the getWidth()/getHeight() methods, the meta data etc. It's a lot of work, and not always straight forward... See the issues and pros/cons from the SO question above.

However, if we disable it by default, it's not that useful... It must work using just ImageIO.read(...), which is what 90% of the library's users ever does. Maybe a way to disable it would be better.

Anyway, I'm not starting implementing this feature tomorrow... ;-)

Harald K

asc75 commented 6 years ago

Hi, are there still plans to implement this? It would be nice if it's handled automatically including the correct (rotated) width and height

haraldk commented 6 years ago

@asc75 It's on the "nice to have" list, but not part of any planned milestone or anything.

asc75 commented 4 years ago

Hi, this feature is still wanted ;)

dProvenzano commented 2 years ago

Would be useful