mirror of
https://github.com/lovell/sharp.git
synced 2025-07-19 23:02:29 +02:00
Ensure autoOrient removes metadata after shrink-on-load #4431
This commit is contained in:
parent
ecfc77c185
commit
628454559e
7
docs/src/content/docs/changelog/v0.34.4.md
Normal file
7
docs/src/content/docs/changelog/v0.34.4.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: v0.34.4 - TBD
|
||||
slug: changelog/v0.34.4
|
||||
---
|
||||
|
||||
* Ensure `autoOrient` removes existing metadata after shrink-on-load.
|
||||
[#4431](https://github.com/lovell/sharp/issues/4431)
|
@ -98,7 +98,6 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
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);
|
||||
}
|
||||
|
||||
rotation = CalculateAngleRotation(baton->angle);
|
||||
@ -294,6 +293,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
throw vips::VError("Input SVG image exceeds 32767x32767 pixel limit");
|
||||
}
|
||||
}
|
||||
if (baton->input->autoOrient) {
|
||||
image = sharp::RemoveExifOrientation(image);
|
||||
}
|
||||
|
||||
// Any pre-shrinking may already have been done
|
||||
inputWidth = image.width();
|
||||
|
@ -322,8 +322,6 @@ describe('Raw pixel data', function () {
|
||||
.gif({ keepDuplicateFrames: true })
|
||||
.toBuffer();
|
||||
|
||||
console.log(await sharp(gif).metadata());
|
||||
|
||||
const { width, height, pages, delay } = await sharp(gif).metadata();
|
||||
assert.strictEqual(width, 1);
|
||||
assert.strictEqual(height, 1);
|
||||
|
@ -635,6 +635,19 @@ describe('Rotation', function () {
|
||||
assert.strictEqual(height, 6);
|
||||
});
|
||||
|
||||
it('Shrink-on-load with autoOrient', async () => {
|
||||
const data = await sharp(fixtures.inputJpgWithLandscapeExif6)
|
||||
.resize(8)
|
||||
.autoOrient()
|
||||
.avif({ effort: 0 })
|
||||
.toBuffer();
|
||||
|
||||
const { width, height, orientation } = await sharp(data).metadata();
|
||||
assert.strictEqual(width, 8);
|
||||
assert.strictEqual(height, 6);
|
||||
assert.strictEqual(orientation, undefined);
|
||||
});
|
||||
|
||||
it('Invalid autoOrient throws', () =>
|
||||
assert.throws(
|
||||
() => sharp({ autoOrient: 'fail' }),
|
||||
|
Loading…
x
Reference in New Issue
Block a user