diff --git a/lib/operation.js b/lib/operation.js index 507f1408..4ac3d069 100644 --- a/lib/operation.js +++ b/lib/operation.js @@ -58,6 +58,8 @@ function rotate (angle, options) { if (this.options.angle || this.options.rotationAngle) { this.options.debuglog('ignoring previous rotate options'); + this.options.angle = 0; + this.options.rotationAngle = 0; } if (is.integer(angle) && !(angle % 90)) { this.options.angle = angle; diff --git a/test/unit/rotate.js b/test/unit/rotate.js index 8c2df5b4..3e3fbd7d 100644 --- a/test/unit/rotate.js +++ b/test/unit/rotate.js @@ -447,6 +447,30 @@ describe('Rotation', function () { assert.strictEqual(warningMessage, 'ignoring previous rotate options'); }); + it('Multiple rotate: last one wins (cardinal)', function (done) { + sharp(fixtures.inputJpg) + .rotate(45) + .rotate(90) + .toBuffer(function (err, data, info) { + if (err) throw err; + assert.strictEqual(2225, info.width); + assert.strictEqual(2725, info.height); + done(); + }); + }); + + it('Multiple rotate: last one wins (non cardinal)', function (done) { + sharp(fixtures.inputJpg) + .rotate(90) + .rotate(45) + .toBuffer(function (err, data, info) { + if (err) throw err; + assert.strictEqual(3500, info.width); + assert.strictEqual(3500, info.height); + done(); + }); + }); + it('Flip - vertical', function (done) { sharp(fixtures.inputJpg) .resize(320)