Tuesday 15 May 2012

java - Implementing automatic rotation of JPEG images according to EXIF Orientation in ImageIO plugin -


background

I have been working on an ImageIO plugin for reading JPEG for some time. If I want to present, according to the EXIF ​​/ TIFF orientation tag, if one is present, automatic rotation of a particular image.

I'm not saying how to implement rotation, but my issue is with the ImageReader API, for many users, just calling imageIO.read (myJPEG) , And they think that the image is happy to be rotated for orientation. However, if you look at it, there are several ways to get information and information about the metadata, and there are several ways to read the pixel data.

Question (s)

Should I highlight a way to read the file in the file, as I am using ImageReadParam (I I can do it in another way, but this will not be allowed to take advantage of the general case mentioned above.

I am working on metadata support (as IIOMetadata ), should the orientation tag written in the metadata file, or the rotated image? This is where I think things get broken ... The real issue here is, what happens when someone reads the image and metadata, then manages to break some of the image and stores it again with metadata (The author should make a strange rotation, or discard the 'magical' orientation tag and update w / h?

... Or alternatively, should I give it now, and the client should have the EXIF Skip to read metadata Should the rotation be applied if necessary?

Input and suggestions implementers as well as ImageIO users are welcome! -)

Due to rotating image

  • The orientation in the FTP metadata is kept, which JPEG / JFIF is not part of standard
  • Reading Exgf metadata adds additional complexity
  • You can get it wrong if Exxie The metadata is incorrect
  • If you include it in the modified file, then you have to modify the XIF metadata.
  • Rotating the image in the context of CPU load and memory can be expensive
  • Unspecified behavior

    image if you read tiles Reasons to Rotate

    • Exif Metadata has been written by almost all digital cameras created after 2010
    • Most digital cameras do not rotate the image, but only in metadata That's why stores store orientation so that additional hardware will be required.
    • For the past two reasons, Exif Orientation can be considered standard and such information should be respected.
    • To provide a better user experience for many viewers, non-users will be able to rotate the image according to the technical user Exif. As a result, users will consider a scene that can not be incomplete or broken.
    • Other metadata information such as color conversion is also applied during reading.

      I think ImageIO should rotate the image and Exif update can work with ImageIO without worrying about the developer image file format like this. And the behavior of the new JPEG reader is compatible with the old.

      Additional attributes

      • To provide a method for reading the image, be unrotated and leave EXIF ​​untouched.
      • To specify the image with the specified orientation.
      • I will not change jpeg writing according to excise metadata because there can be a lot of things in Exif.

        I think we should leave the previous (Exif beeing standard) and to be part of JPEG to consider the orientation in Exif, but I think we can get pixels in memory or screen All other Exif information should still be ignored; -)

No comments:

Post a Comment