Class ExifUtils


  • public final class ExifUtils
    extends java.lang.Object
    An utility class used to obtain the orientation information from a given Exif metadata.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String EXIF_MAGIC_STRING  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ExifUtils()
      This class should not be instantiated.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Orientation getExifOrientation​(javax.imageio.ImageReader reader, int imageIndex)
      Returns the orientation obtained from the Exif metadata.
      static Orientation getOrientationFromExif​(byte[] exifData)
      Returns the orientation obtained from the Exif metadata.
      private static IfdStructure readIFD​(byte[] ifd, java.nio.ByteOrder bo)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EXIF_MAGIC_STRING

        private static final java.lang.String EXIF_MAGIC_STRING
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExifUtils

        private ExifUtils()
        This class should not be instantiated.
    • Method Detail

      • getExifOrientation

        public static Orientation getExifOrientation​(javax.imageio.ImageReader reader,
                                                     int imageIndex)
                                              throws java.io.IOException
        Returns the orientation obtained from the Exif metadata.
        Parameters:
        reader - An ImageReader which is reading the target image.
        imageIndex - The index of the image from which the Exif metadata should be read from.
        Returns:
        The orientation information obtained from the Exif metadata, as a Orientation enum. Returns null if no orientation is found.
        Throws:
        java.io.IOException - When an error occurs during reading.
        java.lang.IllegalArgumentException - If the ImageReader does not have the target image set, or if the reader does not have a JPEG open.
      • getOrientationFromExif

        public static Orientation getOrientationFromExif​(byte[] exifData)
        Returns the orientation obtained from the Exif metadata.
        Parameters:
        exifData - A byte array containing Exif data.
        Returns:
        The orientation information obtained from the Exif metadata, as a Orientation enum. Returns null if no orientation is found.
      • readIFD

        private static IfdStructure readIFD​(byte[] ifd,
                                            java.nio.ByteOrder bo)