mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
fix max factor #29
This commit is contained in:
parent
e32faac17a
commit
39688371a8
@ -211,7 +211,7 @@ class ResizeWorker : public NanAsyncWorker {
|
|||||||
// Recalculate residual float based on dimensions of required vs shrunk images
|
// Recalculate residual float based on dimensions of required vs shrunk images
|
||||||
double residualx = static_cast<double>(baton->width) / static_cast<double>(shrunk->Xsize);
|
double residualx = static_cast<double>(baton->width) / static_cast<double>(shrunk->Xsize);
|
||||||
double residualy = static_cast<double>(baton->height) / static_cast<double>(shrunk->Ysize);
|
double residualy = static_cast<double>(baton->height) / static_cast<double>(shrunk->Ysize);
|
||||||
if (baton->crop) {
|
if (baton->crop || baton->max) {
|
||||||
residual = std::max(residualx, residualy);
|
residual = std::max(residualx, residualy);
|
||||||
} else {
|
} else {
|
||||||
residual = std::min(residualx, residualy);
|
residual = std::min(residualx, residualy);
|
||||||
@ -235,7 +235,7 @@ class ResizeWorker : public NanAsyncWorker {
|
|||||||
// Crop/embed
|
// Crop/embed
|
||||||
VipsImage *canvased = vips_image_new();
|
VipsImage *canvased = vips_image_new();
|
||||||
if (affined->Xsize != baton->width || affined->Ysize != baton->height) {
|
if (affined->Xsize != baton->width || affined->Ysize != baton->height) {
|
||||||
if (baton->crop) {
|
if (baton->crop || baton->max) {
|
||||||
// Crop/max
|
// Crop/max
|
||||||
int width = std::min(affined->Xsize, baton->width);
|
int width = std::min(affined->Xsize, baton->width);
|
||||||
int height = std::min(affined->Ysize, baton->height);
|
int height = std::min(affined->Ysize, baton->height);
|
||||||
@ -359,7 +359,6 @@ NAN_METHOD(resize) {
|
|||||||
} else if (canvas->Equals(NanSymbol("b"))) {
|
} else if (canvas->Equals(NanSymbol("b"))) {
|
||||||
baton->extend = VIPS_EXTEND_BLACK;
|
baton->extend = VIPS_EXTEND_BLACK;
|
||||||
} else if (canvas->Equals(NanSymbol("m"))) {
|
} else if (canvas->Equals(NanSymbol("m"))) {
|
||||||
baton->crop = true;
|
|
||||||
baton->max = true;
|
baton->max = true;
|
||||||
}
|
}
|
||||||
baton->sharpen = args[6]->BooleanValue();
|
baton->sharpen = args[6]->BooleanValue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user