Search code examples
imagemagicksharpimagefilter

Is in sharp js a similar function like imagemagick OilPaint filter for smoothing edges?


I use the image processing sharp-js. In the past I used imagemagick. There is a nice function OilPaint for smoothing edges. i.e. in perl

 $error = $image->[0]->OilPaint( radius => 0 )

Now I want migrate from perl + imagemagick to node + sharp-js.

How can I smooth edges in sharp-js?


Solution

  • There are none filter in sharpjs like OilPaint in imagemagik. But its no problem use sharp-js and graphicsmagick (it use imagemagik) in combination i.e.

    await sharp("cat.png")
        .extract({
          left: ankerX,
          top: ankerY,
          width: sizeX,
          height: sizeY,
        })
        .toFile("cat_section.png");
    
    await gm("cat_section.png")
        .paint(1)
        .write("cat_section_oil.png", function (err) {
          if (err) console.log(err);
          console.log("Oil Done!");
        });
    

    If you want, you can easy write your own filter. Some useful code + instruction you find here Apply a Oil Paint/Sketch effect to a photo using Javascript