在nodejs中使用gm的圆角

在nodejs中使用gm的圆角

问题描述:

我正在尝试使用nodejs对图像进行圆角处理图像。我觉得做这个的最好的库是gm但是因为我不能使用gm我必须使用imagick适配器这样

I am trying to round corners on an image using nodejs to process the images. I feel like the best library to do this would be gm but since I cannot use gm I have to use the imagick adapter as such



var gm = gm.subClass({ imageMagick: true });

gm("img.jpg").autoOrient().resize(50, 50).write('/path', callback);

从这里我无法弄清楚如何获得圆角。我不想在css中这样做,因为它适用于移动应用程序和客户端大小,它会造成滞后。边缘必须平滑。

From here I cannot figure out how to get rounded corners. I do not want to do this in css since it is for a mobile app and client size it makes lags. Edges must be smooth.

imagemagick.convert([
            "-size", width + "x" + height,
            "xc:none",
            "-fill", dest,
            "-draw",
            "circle " + (width / 2) + "," + (width / 2) + " " + (width / 2) + ",1",
            dest
            ], function(err) {
                return done(err);
            });