diff --git a/docs/changelog.md b/docs/changelog.md index 7eb4b3d3..d1455744 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,9 @@ Requires libvips v8.14.2 * Prevent over-compute in affine-based rotate before resize. [#3722](https://github.com/lovell/sharp/issues/3722) +* Allow sequential read for EXIF-based auto-orientation. + [#3725](https://github.com/lovell/sharp/issues/3725) + ### v0.32.1 - 27th April 2023 * Add experimental `unflatten` operation. diff --git a/src/pipeline.cc b/src/pipeline.cc index 6fb9e674..73d2b5af 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -79,6 +79,9 @@ class PipelineWorker : public Napi::AsyncWorker { // Rotate and flip image according to Exif orientation std::tie(autoRotation, autoFlip, autoFlop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image)); image = sharp::RemoveExifOrientation(image); + if (baton->input->access == VIPS_ACCESS_SEQUENTIAL && (autoRotation != VIPS_ANGLE_D0 || autoFlip)) { + image = image.copy_memory(); + } } else { rotation = CalculateAngleRotation(baton->angle); } @@ -1676,7 +1679,6 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) { baton->angle != 0 || baton->rotationAngle != 0.0 || baton->tileAngle != 0 || - baton->useExifOrientation || baton->flip || baton->claheWidth != 0 || !baton->affineMatrix.empty()