mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Fix rotate-then-extract for EXIF orientation 2 (#3218)
This commit is contained in:
parent
51b4a7c564
commit
54d9dc46f5
@ -95,16 +95,18 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
if (baton->rotateBeforePreExtract) {
|
||||
if (rotation != VIPS_ANGLE_D0) {
|
||||
image = image.rot(rotation);
|
||||
}
|
||||
if (flip) {
|
||||
image = image.flip(VIPS_DIRECTION_VERTICAL);
|
||||
flip = FALSE;
|
||||
}
|
||||
if (flop) {
|
||||
image = image.flip(VIPS_DIRECTION_HORIZONTAL);
|
||||
flop = FALSE;
|
||||
}
|
||||
if (rotation != VIPS_ANGLE_D0 || flip || flop) {
|
||||
image = sharp::RemoveExifOrientation(image);
|
||||
}
|
||||
flop = FALSE;
|
||||
flip = FALSE;
|
||||
if (baton->rotationAngle != 0.0) {
|
||||
MultiPageUnsupported(nPages, "Rotate");
|
||||
std::vector<double> background;
|
||||
|
@ -168,8 +168,43 @@ describe('Partial image extraction', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Rotate with EXIF mirroring then extract', function (done) {
|
||||
sharp(fixtures.inputJpgWithLandscapeExif7)
|
||||
describe('Apply exif orientation and mirroring then extract', () => {
|
||||
[
|
||||
{
|
||||
name: 'EXIF-1',
|
||||
image: fixtures.inputJpgWithLandscapeExif1
|
||||
},
|
||||
{
|
||||
name: 'EXIF-2',
|
||||
image: fixtures.inputJpgWithLandscapeExif2
|
||||
},
|
||||
{
|
||||
name: 'EXIF-3',
|
||||
image: fixtures.inputJpgWithLandscapeExif3
|
||||
},
|
||||
{
|
||||
name: 'EXIF-4',
|
||||
image: fixtures.inputJpgWithLandscapeExif4
|
||||
},
|
||||
{
|
||||
name: 'EXIF-5',
|
||||
image: fixtures.inputJpgWithLandscapeExif5
|
||||
},
|
||||
{
|
||||
name: 'EXIF-6',
|
||||
image: fixtures.inputJpgWithLandscapeExif6
|
||||
},
|
||||
{
|
||||
name: 'EXIF-7',
|
||||
image: fixtures.inputJpgWithLandscapeExif7
|
||||
},
|
||||
{
|
||||
name: 'EXIF-8',
|
||||
image: fixtures.inputJpgWithLandscapeExif8
|
||||
}
|
||||
].forEach(({ name, image }) => {
|
||||
it(name, function (done) {
|
||||
sharp(image)
|
||||
.rotate()
|
||||
.extract({ left: 0, top: 208, width: 60, height: 40 })
|
||||
.toBuffer(function (err, data) {
|
||||
@ -177,6 +212,8 @@ describe('Partial image extraction', function () {
|
||||
fixtures.assertSimilar(fixtures.expected('rotate-mirror-extract.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Invalid parameters', function () {
|
||||
describe('using the legacy extract(top,left,width,height) syntax', function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user