Add withoutReduction option to resize operation (#3006)

This commit is contained in:
Chris Banks
2021-12-12 14:10:56 -05:00
committed by GitHub
parent 3b492ea423
commit 446e4e3c3a
7 changed files with 173 additions and 1 deletions

View File

@@ -130,6 +130,17 @@ class PipelineWorker : public Napi::AsyncWorker {
pageHeight = inputHeight;
}
// If withoutReduction is specified,
// Override target width and height if less than respective value from input file
if (baton->withoutReduction) {
if (baton->width < inputWidth) {
baton->width = inputWidth;
}
if (baton->height < inputHeight) {
baton->height = inputHeight;
}
}
// Scaling calculations
double hshrink;
double vshrink;
@@ -1356,6 +1367,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
}
// Resize options
baton->withoutEnlargement = sharp::AttrAsBool(options, "withoutEnlargement");
baton->withoutReduction = sharp::AttrAsBool(options, "withoutReduction");
baton->position = sharp::AttrAsInt32(options, "position");
baton->resizeBackground = sharp::AttrAsVectorOfDouble(options, "resizeBackground");
baton->kernel = sharp::AttrAsStr(options, "kernel");