本文介绍了在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);
            });

这篇关于在nodejs中使用gm的圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 13:51