mirror of
https://github.com/lovell/sharp.git
synced 2025-07-11 19:40:14 +02:00
Ensure ratios are not swapped when rotating 90/270 and ignoring aspect
This commit is contained in:
parent
e576165cf1
commit
25b63a2fb4
@ -26,6 +26,10 @@
|
|||||||
[#367](https://github.com/lovell/sharp/issues/367)
|
[#367](https://github.com/lovell/sharp/issues/367)
|
||||||
[@salzhrani](https://github.com/salzhrani)
|
[@salzhrani](https://github.com/salzhrani)
|
||||||
|
|
||||||
|
* Ensure ratios are not swapped when rotating 90/270 and ignoring aspect.
|
||||||
|
[#387](https://github.com/lovell/sharp/issues/387)
|
||||||
|
[@kleisauke](https://github.com/kleisauke)
|
||||||
|
|
||||||
### v0.13 - "*mind*"
|
### v0.13 - "*mind*"
|
||||||
|
|
||||||
#### v0.13.1 - 27<sup>th</sup> February 2016
|
#### v0.13.1 - 27<sup>th</sup> February 2016
|
||||||
|
@ -194,7 +194,8 @@ class PipelineWorker : public AsyncWorker {
|
|||||||
// Get pre-resize image width and height
|
// Get pre-resize image width and height
|
||||||
int inputWidth = image.width();
|
int inputWidth = image.width();
|
||||||
int inputHeight = image.height();
|
int inputHeight = image.height();
|
||||||
if (!baton->rotateBeforePreExtract && (rotation == VIPS_ANGLE_D90 || rotation == VIPS_ANGLE_D270)) {
|
if (baton->canvas != Canvas::IGNORE_ASPECT && !baton->rotateBeforePreExtract &&
|
||||||
|
(rotation == VIPS_ANGLE_D90 || rotation == VIPS_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
|
||||||
std::swap(inputWidth, inputHeight);
|
std::swap(inputWidth, inputHeight);
|
||||||
}
|
}
|
||||||
@ -392,7 +393,8 @@ class PipelineWorker : public AsyncWorker {
|
|||||||
// Recalculate residual float based on dimensions of required vs shrunk images
|
// Recalculate residual float based on dimensions of required vs shrunk images
|
||||||
int shrunkWidth = image.width();
|
int shrunkWidth = image.width();
|
||||||
int shrunkHeight = image.height();
|
int shrunkHeight = image.height();
|
||||||
if (rotation == VIPS_ANGLE_D90 || rotation == VIPS_ANGLE_D270) {
|
if (baton->canvas != Canvas::IGNORE_ASPECT && !baton->rotateBeforePreExtract &&
|
||||||
|
(rotation == VIPS_ANGLE_D90 || rotation == VIPS_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
|
||||||
std::swap(shrunkWidth, shrunkHeight);
|
std::swap(shrunkWidth, shrunkHeight);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,23 @@ describe('Rotation', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Rotate by 270 degrees, square output ignoring aspect ratio', function(done) {
|
||||||
|
sharp(fixtures.inputJpg)
|
||||||
|
.resize(240, 240)
|
||||||
|
.ignoreAspectRatio()
|
||||||
|
.rotate(270)
|
||||||
|
.toBuffer(function(err, data, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(240, info.width);
|
||||||
|
assert.strictEqual(240, info.height);
|
||||||
|
sharp(data).metadata(function(err, metadata) {
|
||||||
|
assert.strictEqual(240, metadata.width);
|
||||||
|
assert.strictEqual(240, metadata.height);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Input image has Orientation EXIF tag but do not rotate output', function(done) {
|
it('Input image has Orientation EXIF tag but do not rotate output', function(done) {
|
||||||
sharp(fixtures.inputJpgWithExif)
|
sharp(fixtures.inputJpgWithExif)
|
||||||
.resize(320)
|
.resize(320)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user