JPEG EXIF rotation tag is not considered
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:
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.
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.
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? ...
Perhaps the metadata-extractor library could help us? But this maybe an overkill...