Пример #1
0
        /// <summary>
        /// Get orientation information from jpeg input stream.
        /// </summary>
        /// <param name="inputStream">
        /// The input stream of jpeg image.
        /// </param>
        /// <returns>
        /// Orientation: 1/8/3/6.
        /// Returns 0 if there is no valid orientation information.
        /// </returns>
        public static int GetOrientation(Stream inputStream)
        {
            try
            {
                int length = MoveToAPP1EXIF(inputStream);
                if (length == 0)
                {
                    return(0); // unknown orientation
                }

                return(TiffUtil.ReadOrientationFromTIFF(inputStream, length));
            }
            catch (IOException)
            {
                return(0);
            }
        }
Пример #2
0
 /// <summary>
 /// Determines auto-rotate angle based on orientation information.
 /// </summary>
 /// <param name="orientation">
 /// Orientation information, one of {1, 3, 6, 8}.
 /// </param>
 /// <returns>
 /// Orientation: 1/3/6/8 -> 0/180/90/270.
 /// </returns>
 public static int GetAutoRotateAngleFromOrientation(int orientation)
 {
     return(TiffUtil.GetAutoRotateAngleFromOrientation(orientation));
 }