Fix rotate/extract ordering for non-90 angles (#1755)

This commit is contained in:
Ilya Ovdin
2019-07-26 22:28:45 +03:00
committed by Lovell Fuller
parent 50b461024d
commit 690bc43abe
5 changed files with 44 additions and 10 deletions

View File

@@ -108,9 +108,16 @@ class PipelineWorker : public Nan::AsyncWorker {
}
// Rotate pre-extract
if (baton->rotateBeforePreExtract && rotation != VIPS_ANGLE_D0) {
image = image.rot(rotation);
sharp::RemoveExifOrientation(image);
if (baton->rotateBeforePreExtract) {
if (rotation != VIPS_ANGLE_D0) {
image = image.rot(rotation);
sharp::RemoveExifOrientation(image);
}
if (baton->rotationAngle != 0.0) {
std::vector<double> background;
std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground);
image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background));
}
}
// Trim
@@ -403,12 +410,13 @@ class PipelineWorker : public Nan::AsyncWorker {
->set("kernel", kernel));
}
// Rotate
if (!baton->rotateBeforePreExtract && rotation != VIPS_ANGLE_D0) {
image = image.rot(rotation);
sharp::RemoveExifOrientation(image);
// Rotate post-extract 90-angle
if (!baton->rotateBeforePreExtract && rotation != VIPS_ANGLE_D0) {
image = image.rot(rotation);
sharp::RemoveExifOrientation(image);
}
// Flip (mirror about Y axis)
if (baton->flip) {
image = image.flip(VIPS_DIRECTION_VERTICAL);
@@ -491,8 +499,8 @@ class PipelineWorker : public Nan::AsyncWorker {
}
}
// Rotate by degree
if (baton->rotationAngle != 0.0) {
// Rotate post-extract non-90 angle
if (!baton->rotateBeforePreExtract && baton->rotationAngle != 0.0) {
std::vector<double> background;
std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground);
image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background));