mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add withoutReduction option to resize operation (#3006)
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -119,6 +119,7 @@ struct PipelineBaton {
|
||||
int extendRight;
|
||||
std::vector<double> extendBackground;
|
||||
bool withoutEnlargement;
|
||||
bool withoutReduction;
|
||||
std::vector<double> affineMatrix;
|
||||
std::vector<double> affineBackground;
|
||||
double affineIdx;
|
||||
@@ -259,6 +260,7 @@ struct PipelineBaton {
|
||||
extendRight(0),
|
||||
extendBackground{ 0.0, 0.0, 0.0, 255.0 },
|
||||
withoutEnlargement(false),
|
||||
withoutReduction(false),
|
||||
affineMatrix{ 1.0, 0.0, 0.0, 1.0 },
|
||||
affineBackground{ 0.0, 0.0, 0.0, 255.0 },
|
||||
affineIdx(0),
|
||||
|
||||
Reference in New Issue
Block a user