mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Ensure flip and flop operations work with auto-rotate #837
This commit is contained in:
parent
29354badd8
commit
49297d6afb
@ -10,6 +10,10 @@ Requires libvips v8.5.5.
|
|||||||
[#828](https://github.com/lovell/sharp/pull/828)
|
[#828](https://github.com/lovell/sharp/pull/828)
|
||||||
[@YvesBos](https://github.com/YvesBos)
|
[@YvesBos](https://github.com/YvesBos)
|
||||||
|
|
||||||
|
* Ensure flip and flop operations work with auto-rotate.
|
||||||
|
[#837](https://github.com/lovell/sharp/issues/837)
|
||||||
|
[@rexxars](https://github.com/rexxars)
|
||||||
|
|
||||||
#### v0.18.1 - 30<sup>th</sup> May 2017
|
#### v0.18.1 - 30<sup>th</sup> May 2017
|
||||||
|
|
||||||
* Remove regression from #781 that could cause incorrect shrink calculation.
|
* Remove regression from #781 that could cause incorrect shrink calculation.
|
||||||
|
@ -83,8 +83,11 @@ class PipelineWorker : public Nan::AsyncWorker {
|
|||||||
VipsAngle rotation;
|
VipsAngle rotation;
|
||||||
if (baton->useExifOrientation) {
|
if (baton->useExifOrientation) {
|
||||||
// Rotate and flip image according to Exif orientation
|
// Rotate and flip image according to Exif orientation
|
||||||
// (ignore the requested rotation and flip)
|
bool flip;
|
||||||
std::tie(rotation, baton->flip, baton->flop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
|
bool flop;
|
||||||
|
std::tie(rotation, flip, flop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
|
||||||
|
baton->flip = baton->flip || flip;
|
||||||
|
baton->flop = baton->flop || flop;
|
||||||
} else {
|
} else {
|
||||||
rotation = CalculateAngleRotation(baton->angle);
|
rotation = CalculateAngleRotation(baton->angle);
|
||||||
}
|
}
|
||||||
|
BIN
test/fixtures/expected/rotate-and-flip.jpg
vendored
Normal file
BIN
test/fixtures/expected/rotate-and-flip.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
test/fixtures/expected/rotate-and-flop.jpg
vendored
Normal file
BIN
test/fixtures/expected/rotate-and-flop.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
@ -253,4 +253,32 @@ describe('Rotation', function () {
|
|||||||
fixtures.assertSimilar(fixtures.inputJpg, data, done);
|
fixtures.assertSimilar(fixtures.inputJpg, data, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Auto-rotate and flip', function (done) {
|
||||||
|
sharp(fixtures.inputJpgWithExif)
|
||||||
|
.rotate()
|
||||||
|
.flip()
|
||||||
|
.resize(320)
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual('jpeg', info.format);
|
||||||
|
assert.strictEqual(320, info.width);
|
||||||
|
assert.strictEqual(240, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('rotate-and-flip.jpg'), data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Auto-rotate and flop', function (done) {
|
||||||
|
sharp(fixtures.inputJpgWithExif)
|
||||||
|
.rotate()
|
||||||
|
.flop()
|
||||||
|
.resize(320)
|
||||||
|
.toBuffer(function (err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual('jpeg', info.format);
|
||||||
|
assert.strictEqual(320, info.width);
|
||||||
|
assert.strictEqual(240, info.height);
|
||||||
|
fixtures.assertSimilar(fixtures.expected('rotate-and-flop.jpg'), data, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user