audiveris icon indicating copy to clipboard operation
audiveris copied to clipboard

JPEG EXIF rotation tag is not considered

Open Eiim opened this issue 1 year ago • 4 comments

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

Eiim avatar Jun 06 '24 18:06 Eiim

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

  • The user could manually rotate the image via some external tool before submitting it to Audiveris. This is the current situation. It may require to extract the image, rotate it and insert it back into the containing book.
  • Or the user could explicitly ask Audiveris to directly rotate the sheet at hand by +90 or -90 degrees (feature not yet implemented).

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

hbitteur avatar Jun 07 '24 07:06 hbitteur

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.

Eiim avatar Jun 07 '24 13:06 Eiim

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 avatar Jun 07 '24 15:06 hbitteur

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

hbitteur avatar Jun 07 '24 16:06 hbitteur