Audiveris / audiveris

Latest generation of Audiveris OMR engine
https://audiveris.github.io/audiveris
GNU Affero General Public License v3.0
1.45k stars 217 forks source link

JPEG EXIF rotation tag is not considered #736

Open Eiim opened 4 weeks ago

Eiim commented 4 weeks ago

JPEGs can be rotated through an EXIF orientation tag. This doesn't change the underlying image data, only how it should be interpreted. Unfortunately, Java's ImageIO library doesn't consider this tag, so images can be read with the incorrect rotation. For example, this image (intentionally not sheet music):

is read into Audiveris like so: image

hbitteur commented 4 weeks ago

If the Audiveris engine has no way to detect this rotation by itself, what should we do?

In both cases, some user action is needed of course.

Eiim commented 4 weeks ago

It should be possible to read the EXIF tags with ImageReader.getImageMetadata(). It appears that internally, the orientation is used here when reading dimension metadata, but I'm admittedly not sure what the right way to get that information is. I might play around with it later and see if I can find a solution.

hbitteur commented 4 weeks ago

In the code you mention, the "orient" variable is created from scratch and its value coded to "normal". It is then inserted (or appended?) to the "dim" variable.

It does not seem to be read from the image data. Perhaps in some other part of ImageIO code? ...

hbitteur commented 4 weeks ago

Perhaps the metadata-extractor library could help us? But this maybe an overkill...