Pre-extract rotate should not swap width/height #296

This commit is contained in:
Lovell Fuller 2015-11-11 22:34:30 +00:00
parent d7278f022b
commit 58d9e0fef7
4 changed files with 9 additions and 9 deletions

View File

@ -285,7 +285,7 @@ class PipelineWorker : public AsyncWorker {
// Get pre-resize image width and height // Get pre-resize image width and height
int inputWidth = image->Xsize; int inputWidth = image->Xsize;
int inputHeight = image->Ysize; 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 // Swap input output width and height when rotating by 90 or 270 degrees
int swap = inputWidth; int swap = inputWidth;
inputWidth = inputHeight; inputWidth = inputHeight;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -96,25 +96,25 @@ describe('Partial image extraction', function() {
}); });
it('Extract then rotate', function(done) { it('Extract then rotate', function(done) {
sharp(fixtures.inputJpg) sharp(fixtures.inputPngWithGreyAlpha)
.extract(10, 10, 100, 100) .extract(10, 20, 380, 280)
.rotate(90) .rotate(90)
.toBuffer(function(err, data, info) { .toBuffer(function(err, data, info) {
if (err) throw err; if (err) throw err;
assert.strictEqual(100, info.width); assert.strictEqual(280, info.width);
assert.strictEqual(100, info.height); assert.strictEqual(380, info.height);
fixtures.assertSimilar(fixtures.expected('extract-rotate.jpg'), data, done); fixtures.assertSimilar(fixtures.expected('extract-rotate.jpg'), data, done);
}); });
}); });
it('Rotate then extract', function(done) { it('Rotate then extract', function(done) {
sharp(fixtures.inputJpg) sharp(fixtures.inputPngWithGreyAlpha)
.rotate(90) .rotate(90)
.extract(10, 10, 100, 100) .extract(10, 20, 280, 380)
.toBuffer(function(err, data, info) { .toBuffer(function(err, data, info) {
if (err) throw err; if (err) throw err;
assert.strictEqual(100, info.width); assert.strictEqual(280, info.width);
assert.strictEqual(100, info.height); assert.strictEqual(380, info.height);
fixtures.assertSimilar(fixtures.expected('rotate-extract.jpg'), data, done); fixtures.assertSimilar(fixtures.expected('rotate-extract.jpg'), data, done);
}); });
}); });