From 115a6b10f65d9a45843449cb9a28ec56606940ed Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 9 Feb 2022 15:45:11 +0100 Subject: [PATCH] Ensure affineInterpolator is correctly finalised (#3083) --- src/pipeline.cc | 6 ++++-- src/pipeline.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pipeline.cc b/src/pipeline.cc index 90b09df74..a426dfbb3 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -518,12 +518,14 @@ class PipelineWorker : public Napi::AsyncWorker { MultiPageUnsupported(nPages, "Affine"); std::vector background; std::tie(image, background) = sharp::ApplyAlpha(image, baton->affineBackground, shouldPremultiplyAlpha); + vips::VInterpolate interp = vips::VInterpolate::new_from_name( + const_cast(baton->affineInterpolator.data())); image = image.affine(baton->affineMatrix, VImage::option()->set("background", background) ->set("idx", baton->affineIdx) ->set("idy", baton->affineIdy) ->set("odx", baton->affineOdx) ->set("ody", baton->affineOdy) - ->set("interpolate", baton->affineInterpolator)); + ->set("interpolate", interp)); } // Extend edges @@ -1428,7 +1430,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) { baton->affineIdy = sharp::AttrAsDouble(options, "affineIdy"); baton->affineOdx = sharp::AttrAsDouble(options, "affineOdx"); baton->affineOdy = sharp::AttrAsDouble(options, "affineOdy"); - baton->affineInterpolator = vips::VInterpolate::new_from_name(sharp::AttrAsStr(options, "affineInterpolator").data()); + baton->affineInterpolator = sharp::AttrAsStr(options, "affineInterpolator"); baton->removeAlpha = sharp::AttrAsBool(options, "removeAlpha"); baton->ensureAlpha = sharp::AttrAsDouble(options, "ensureAlpha"); if (options.Has("boolean")) { diff --git a/src/pipeline.h b/src/pipeline.h index 0b27f5a9a..90e808d92 100644 --- a/src/pipeline.h +++ b/src/pipeline.h @@ -126,7 +126,7 @@ struct PipelineBaton { double affineIdy; double affineOdx; double affineOdy; - vips::VInterpolate affineInterpolator; + std::string affineInterpolator; int jpegQuality; bool jpegProgressive; std::string jpegChromaSubsampling; @@ -268,7 +268,7 @@ struct PipelineBaton { affineIdy(0), affineOdx(0), affineOdy(0), - affineInterpolator(vips::VInterpolate::new_from_name("bicubic")), + affineInterpolator("bicubic"), jpegQuality(80), jpegProgressive(false), jpegChromaSubsampling("4:2:0"),