mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Pre-extract rotate should not swap width/height #296
This commit is contained in:
parent
d7278f022b
commit
58d9e0fef7
@ -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;
|
||||||
|
BIN
test/fixtures/expected/extract-rotate.jpg
vendored
BIN
test/fixtures/expected/extract-rotate.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 5.2 KiB |
BIN
test/fixtures/expected/rotate-extract.jpg
vendored
BIN
test/fixtures/expected/rotate-extract.jpg
vendored
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 5.3 KiB |
@ -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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user