fix max factor #29

This commit is contained in:
Pierre Inglebert 2014-05-24 10:29:33 +02:00
parent e32faac17a
commit 39688371a8

View File

@ -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();