Skip to content

Commit

Permalink
Drop options.useExifOrientation in favor of options.input.autoOrient
Browse files Browse the repository at this point in the history
  • Loading branch information
happycollision committed Jul 14, 2024
1 parent 189b6e8 commit 94cd456
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 8 deletions.
2 changes: 0 additions & 2 deletions lib/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ const Sharp = function (input, options) {
canvas: 'crop',
position: 0,
resizeBackground: [0, 0, 0, 255],
useExifOrientation: false,
angle: 0,
rotationAngle: 0,
rotationBackground: [0, 0, 0, 255],
Expand Down Expand Up @@ -357,7 +356,6 @@ const Sharp = function (input, options) {
}
};
this.options.input = this._createInputDescriptor(input, options, { allowStream: true });
this.options.useExifOrientation = !!this.options.input.autoOrient;
return this;
};
Object.setPrototypeOf(Sharp.prototype, stream.Duplex.prototype);
Expand Down
2 changes: 1 addition & 1 deletion lib/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function rotate (angle, options) {
* @returns {Sharp}
*/
function autoOrient () {
this.options.useExifOrientation = true;
this.options.input.autoOrient = true;
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const mapFitToCanvas = {
* @private
*/
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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PipelineWorker : public Napi::AsyncWorker {
bool autoFlip = false;
bool autoFlop = false;

if (baton->useExifOrientation) {
if (baton->input->autoOrient) {
// Rotate and flip image according to Exif orientation
std::tie(autoRotation, autoFlip, autoFlop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
image = sharp::RemoveExifOrientation(image);
Expand Down Expand Up @@ -1591,7 +1591,6 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
baton->claheWidth = sharp::AttrAsUint32(options, "claheWidth");
baton->claheHeight = sharp::AttrAsUint32(options, "claheHeight");
baton->claheMaxSlope = sharp::AttrAsUint32(options, "claheMaxSlope");
baton->useExifOrientation = sharp::AttrAsBool(options, "useExifOrientation");
baton->angle = sharp::AttrAsInt32(options, "angle");
baton->rotationAngle = sharp::AttrAsDouble(options, "rotationAngle");
baton->rotationBackground = sharp::AttrAsVectorOfDouble(options, "rotationBackground");
Expand Down
2 changes: 0 additions & 2 deletions src/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ struct PipelineBaton {
int claheWidth;
int claheHeight;
int claheMaxSlope;
bool useExifOrientation;
int angle;
double rotationAngle;
std::vector<double> rotationBackground;
Expand Down Expand Up @@ -279,7 +278,6 @@ struct PipelineBaton {
claheWidth(0),
claheHeight(0),
claheMaxSlope(3),
useExifOrientation(false),
angle(0),
rotationAngle(0.0),
rotationBackground{ 0.0, 0.0, 0.0, 255.0 },
Expand Down

0 comments on commit 94cd456

Please sign in to comment.