Ensure flip and flop operations work with auto-rotate #837

This commit is contained in:
Lovell Fuller 2017-06-19 23:42:26 +01:00
parent 29354badd8
commit 49297d6afb
5 changed files with 37 additions and 2 deletions

View File

@ -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.

View File

@ -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);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -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);
});
});
}); });