mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure op ordering is respected where possible #3319
Emit warnings when previous ops might be ignored Flip and flop now occur before rotate, if any
This commit is contained in:
@@ -951,7 +951,7 @@ namespace sharp {
|
||||
|
||||
std::pair<double, double> ResolveShrink(int width, int height, int targetWidth, int targetHeight,
|
||||
Canvas canvas, bool swap, bool withoutEnlargement, bool withoutReduction) {
|
||||
if (swap) {
|
||||
if (swap && canvas != Canvas::IGNORE_ASPECT) {
|
||||
// Swap input width and height when requested.
|
||||
std::swap(width, height);
|
||||
}
|
||||
@@ -982,9 +982,6 @@ namespace sharp {
|
||||
}
|
||||
break;
|
||||
case Canvas::IGNORE_ASPECT:
|
||||
if (swap) {
|
||||
std::swap(hshrink, vshrink);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (targetWidth > 0) {
|
||||
|
||||
@@ -387,6 +387,18 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
->set("kernel", kernel));
|
||||
}
|
||||
|
||||
// Flip (mirror about Y axis)
|
||||
if (baton->flip || flip) {
|
||||
image = image.flip(VIPS_DIRECTION_VERTICAL);
|
||||
image = sharp::RemoveExifOrientation(image);
|
||||
}
|
||||
|
||||
// Flop (mirror about X axis)
|
||||
if (baton->flop || flop) {
|
||||
image = image.flip(VIPS_DIRECTION_HORIZONTAL);
|
||||
image = sharp::RemoveExifOrientation(image);
|
||||
}
|
||||
|
||||
// Rotate post-extract 90-angle
|
||||
if (!baton->rotateBeforePreExtract && rotation != VIPS_ANGLE_D0) {
|
||||
image = image.rot(rotation);
|
||||
@@ -401,18 +413,6 @@ class PipelineWorker : public Napi::AsyncWorker {
|
||||
image = sharp::RemoveExifOrientation(image);
|
||||
}
|
||||
|
||||
// Flip (mirror about Y axis)
|
||||
if (baton->flip || flip) {
|
||||
image = image.flip(VIPS_DIRECTION_VERTICAL);
|
||||
image = sharp::RemoveExifOrientation(image);
|
||||
}
|
||||
|
||||
// Flop (mirror about X axis)
|
||||
if (baton->flop || flop) {
|
||||
image = image.flip(VIPS_DIRECTION_HORIZONTAL);
|
||||
image = sharp::RemoveExifOrientation(image);
|
||||
}
|
||||
|
||||
// Join additional color channels to the image
|
||||
if (baton->joinChannelIn.size() > 0) {
|
||||
VImage joinImage;
|
||||
|
||||
Reference in New Issue
Block a user