Drop options.useExifOrientation in favor of options.input.autoOrient

This commit is contained in:
Don Denton 2024-07-14 00:04:36 -04:00
parent 8e7c7b4196
commit 7169a2555e
5 changed files with 3 additions and 8 deletions

View File

@ -194,7 +194,6 @@ const Sharp = function (input, options) {
canvas: 'crop', canvas: 'crop',
position: 0, position: 0,
resizeBackground: [0, 0, 0, 255], resizeBackground: [0, 0, 0, 255],
useExifOrientation: false,
angle: 0, angle: 0,
rotationAngle: 0, rotationAngle: 0,
rotationBackground: [0, 0, 0, 255], rotationBackground: [0, 0, 0, 255],
@ -362,7 +361,6 @@ const Sharp = function (input, options) {
} }
}; };
this.options.input = this._createInputDescriptor(input, options, { allowStream: true }); this.options.input = this._createInputDescriptor(input, options, { allowStream: true });
this.options.useExifOrientation = !!this.options.input.autoOrient;
return this; return this;
}; };
Object.setPrototypeOf(Sharp.prototype, stream.Duplex.prototype); Object.setPrototypeOf(Sharp.prototype, stream.Duplex.prototype);

View File

@ -102,7 +102,7 @@ function rotate (angle, options) {
* @returns {Sharp} * @returns {Sharp}
*/ */
function autoOrient () { function autoOrient () {
this.options.useExifOrientation = true; this.options.input.autoOrient = true;
return this; return this;
} }

View File

@ -107,7 +107,7 @@ const mapFitToCanvas = {
* @private * @private
*/ */
function isRotationExpected (options) { function isRotationExpected (options) {
return (options.angle % 360) !== 0 || options.useExifOrientation === true || options.rotationAngle !== 0; return (options.angle % 360) !== 0 || options.input.autoOrient === true || options.rotationAngle !== 0;
} }
/** /**

View File

@ -63,7 +63,7 @@ class PipelineWorker : public Napi::AsyncWorker {
bool autoFlip = false; bool autoFlip = false;
bool autoFlop = false; bool autoFlop = false;
if (baton->useExifOrientation) { if (baton->input->autoOrient) {
// Rotate and flip image according to Exif orientation // Rotate and flip image according to Exif orientation
std::tie(autoRotation, autoFlip, autoFlop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image)); std::tie(autoRotation, autoFlip, autoFlop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
image = sharp::RemoveExifOrientation(image); image = sharp::RemoveExifOrientation(image);
@ -1589,7 +1589,6 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
baton->claheWidth = sharp::AttrAsUint32(options, "claheWidth"); baton->claheWidth = sharp::AttrAsUint32(options, "claheWidth");
baton->claheHeight = sharp::AttrAsUint32(options, "claheHeight"); baton->claheHeight = sharp::AttrAsUint32(options, "claheHeight");
baton->claheMaxSlope = sharp::AttrAsUint32(options, "claheMaxSlope"); baton->claheMaxSlope = sharp::AttrAsUint32(options, "claheMaxSlope");
baton->useExifOrientation = sharp::AttrAsBool(options, "useExifOrientation");
baton->angle = sharp::AttrAsInt32(options, "angle"); baton->angle = sharp::AttrAsInt32(options, "angle");
baton->rotationAngle = sharp::AttrAsDouble(options, "rotationAngle"); baton->rotationAngle = sharp::AttrAsDouble(options, "rotationAngle");
baton->rotationBackground = sharp::AttrAsVectorOfDouble(options, "rotationBackground"); baton->rotationBackground = sharp::AttrAsVectorOfDouble(options, "rotationBackground");

View File

@ -109,7 +109,6 @@ struct PipelineBaton {
int claheWidth; int claheWidth;
int claheHeight; int claheHeight;
int claheMaxSlope; int claheMaxSlope;
bool useExifOrientation;
int angle; int angle;
double rotationAngle; double rotationAngle;
std::vector<double> rotationBackground; std::vector<double> rotationBackground;
@ -282,7 +281,6 @@ struct PipelineBaton {
claheWidth(0), claheWidth(0),
claheHeight(0), claheHeight(0),
claheMaxSlope(3), claheMaxSlope(3),
useExifOrientation(false),
angle(0), angle(0),
rotationAngle(0.0), rotationAngle(0.0),
rotationBackground{ 0.0, 0.0, 0.0, 255.0 }, rotationBackground{ 0.0, 0.0, 0.0, 255.0 },