mirror of
https://github.com/lovell/sharp.git
synced 2025-07-26 01:32:27 +02:00
Fix double rotate behavior
Docs and warnings state that we ignore previous calls to `.rotate()` when multiple calls are made, but we were not correctly resetting the state at the start of the second call.
This commit is contained in:
parent
7169a2555e
commit
ab884e13cf
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user