diff --git a/src/pipeline.cc b/src/pipeline.cc index 82212675..26a493eb 100755 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -285,7 +285,7 @@ class PipelineWorker : public AsyncWorker { // Get pre-resize image width and height int inputWidth = image->Xsize; int inputHeight = image->Ysize; - if (rotation == Angle::D90 || rotation == Angle::D270) { + if (!baton->rotateBeforePreExtract && (rotation == Angle::D90 || rotation == Angle::D270)) { // Swap input output width and height when rotating by 90 or 270 degrees int swap = inputWidth; inputWidth = inputHeight; diff --git a/test/fixtures/expected/extract-rotate.jpg b/test/fixtures/expected/extract-rotate.jpg index 9ad6d34b..ecd6e78a 100644 Binary files a/test/fixtures/expected/extract-rotate.jpg and b/test/fixtures/expected/extract-rotate.jpg differ diff --git a/test/fixtures/expected/rotate-extract.jpg b/test/fixtures/expected/rotate-extract.jpg index ab7bb3d9..d27753ce 100644 Binary files a/test/fixtures/expected/rotate-extract.jpg and b/test/fixtures/expected/rotate-extract.jpg differ diff --git a/test/unit/extract.js b/test/unit/extract.js index 9a1f2f79..4497e048 100755 --- a/test/unit/extract.js +++ b/test/unit/extract.js @@ -96,25 +96,25 @@ describe('Partial image extraction', function() { }); it('Extract then rotate', function(done) { - sharp(fixtures.inputJpg) - .extract(10, 10, 100, 100) + sharp(fixtures.inputPngWithGreyAlpha) + .extract(10, 20, 380, 280) .rotate(90) .toBuffer(function(err, data, info) { if (err) throw err; - assert.strictEqual(100, info.width); - assert.strictEqual(100, info.height); + assert.strictEqual(280, info.width); + assert.strictEqual(380, info.height); fixtures.assertSimilar(fixtures.expected('extract-rotate.jpg'), data, done); }); }); it('Rotate then extract', function(done) { - sharp(fixtures.inputJpg) + sharp(fixtures.inputPngWithGreyAlpha) .rotate(90) - .extract(10, 10, 100, 100) + .extract(10, 20, 280, 380) .toBuffer(function(err, data, info) { if (err) throw err; - assert.strictEqual(100, info.width); - assert.strictEqual(100, info.height); + assert.strictEqual(280, info.width); + assert.strictEqual(380, info.height); fixtures.assertSimilar(fixtures.expected('rotate-extract.jpg'), data, done); }); });