Skip to content

Commit 6284545

Browse files
committed
Ensure autoOrient removes metadata after shrink-on-load #4431
1 parent ecfc77c commit 6284545

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: v0.34.4 - TBD
3+
slug: changelog/v0.34.4
4+
---
5+
6+
* Ensure `autoOrient` removes existing metadata after shrink-on-load.
7+
[#4431](https://github.com/lovell/sharp/issues/4431)

src/pipeline.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ class PipelineWorker : public Napi::AsyncWorker {
9898
if (baton->input->autoOrient) {
9999
// Rotate and flip image according to Exif orientation
100100
std::tie(autoRotation, autoFlip, autoFlop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
101-
image = sharp::RemoveExifOrientation(image);
102101
}
103102

104103
rotation = CalculateAngleRotation(baton->angle);
@@ -294,6 +293,9 @@ class PipelineWorker : public Napi::AsyncWorker {
294293
throw vips::VError("Input SVG image exceeds 32767x32767 pixel limit");
295294
}
296295
}
296+
if (baton->input->autoOrient) {
297+
image = sharp::RemoveExifOrientation(image);
298+
}
297299

298300
// Any pre-shrinking may already have been done
299301
inputWidth = image.width();

test/unit/raw.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,6 @@ describe('Raw pixel data', function () {
322322
.gif({ keepDuplicateFrames: true })
323323
.toBuffer();
324324

325-
console.log(await sharp(gif).metadata());
326-
327325
const { width, height, pages, delay } = await sharp(gif).metadata();
328326
assert.strictEqual(width, 1);
329327
assert.strictEqual(height, 1);

test/unit/rotate.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,19 @@ describe('Rotation', function () {
635635
assert.strictEqual(height, 6);
636636
});
637637

638+
it('Shrink-on-load with autoOrient', async () => {
639+
const data = await sharp(fixtures.inputJpgWithLandscapeExif6)
640+
.resize(8)
641+
.autoOrient()
642+
.avif({ effort: 0 })
643+
.toBuffer();
644+
645+
const { width, height, orientation } = await sharp(data).metadata();
646+
assert.strictEqual(width, 8);
647+
assert.strictEqual(height, 6);
648+
assert.strictEqual(orientation, undefined);
649+
});
650+
638651
it('Invalid autoOrient throws', () =>
639652
assert.throws(
640653
() => sharp({ autoOrient: 'fail' }),

0 commit comments

Comments
 (0)