@@ -94,19 +94,39 @@ Exif orientation values to correctly display the letter F:
9494 )
9595 }
9696
97+ /**
98+ * Determines if the image requires orientation.
99+ *
100+ * @param {object } [options] Options object
101+ * @param {boolean } [withMetaData] Is meta data required for orientation
102+ * @returns {boolean } Returns true if the image requires orientation
103+ */
104+ function requiresOrientation ( options , withMetaData ) {
105+ var orientation = options && options . orientation
106+ return (
107+ // Exif orientation for browsers without automatic image orientation:
108+ ( orientation === true && ! loadImage . orientation ) ||
109+ // Orientation reset for browsers with automatic image orientation:
110+ ( orientation === 1 && loadImage . orientation ) ||
111+ // Orientation to defined value, requires meta data for orientation reset:
112+ ( ( ! withMetaData || loadImage . orientation ) &&
113+ orientation > 1 &&
114+ orientation < 9 )
115+ )
116+ }
117+
97118 // Determines if the target image should be a canvas element:
98119 loadImage . requiresCanvas = function ( options ) {
99120 return (
100- ( options . orientation === true && ! loadImage . orientation ) ||
101- ( options . orientation > 1 && options . orientation < 9 ) ||
121+ requiresOrientation ( options ) ||
102122 originalRequiresCanvas . call ( loadImage , options )
103123 )
104124 }
105125
106126 // Determines if meta data should be loaded automatically:
107127 loadImage . requiresMetaData = function ( options ) {
108128 return (
109- ( options && options . orientation === true && ! loadImage . orientation ) ||
129+ requiresOrientation ( options , true ) ||
110130 originalRequiresMetaData . call ( loadImage , options )
111131 )
112132 }
0 commit comments