mirror of
https://github.com/lovell/sharp.git
synced 2025-12-18 23:05:04 +01:00
Ensure autoOrient occurs before non-90 rotation #4425
- Separate orient vs rotate ordering logic - Simplify EXIF auto-orient by using only rotate and/or flop
This commit is contained in:
@@ -230,7 +230,8 @@ const Sharp = function (input, options) {
|
||||
angle: 0,
|
||||
rotationAngle: 0,
|
||||
rotationBackground: [0, 0, 0, 255],
|
||||
rotateBeforePreExtract: false,
|
||||
rotateBefore: false,
|
||||
orientBefore: false,
|
||||
flip: false,
|
||||
flop: false,
|
||||
extendTop: 0,
|
||||
|
||||
@@ -107,7 +107,7 @@ const mapFitToCanvas = {
|
||||
* @private
|
||||
*/
|
||||
function isRotationExpected (options) {
|
||||
return (options.angle % 360) !== 0 || options.input.autoOrient === true || options.rotationAngle !== 0;
|
||||
return (options.angle % 360) !== 0 || options.rotationAngle !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,7 +343,7 @@ function resize (widthOrOptions, height, options) {
|
||||
}
|
||||
}
|
||||
if (isRotationExpected(this.options) && isResizeExpected(this.options)) {
|
||||
this.options.rotateBeforePreExtract = true;
|
||||
this.options.rotateBefore = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -490,9 +490,12 @@ function extract (options) {
|
||||
// Ensure existing rotation occurs before pre-resize extraction
|
||||
if (isRotationExpected(this.options) && !isResizeExpected(this.options)) {
|
||||
if (this.options.widthPre === -1 || this.options.widthPost === -1) {
|
||||
this.options.rotateBeforePreExtract = true;
|
||||
this.options.rotateBefore = true;
|
||||
}
|
||||
}
|
||||
if (this.options.input.autoOrient) {
|
||||
this.options.orientBefore = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -566,7 +569,7 @@ function trim (options) {
|
||||
}
|
||||
}
|
||||
if (isRotationExpected(this.options)) {
|
||||
this.options.rotateBeforePreExtract = true;
|
||||
this.options.rotateBefore = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user