开发者

node-canvas image manipulation

I'm trying to resize and crop an image in node.js

I've been using graphicsmagick:

code is as follows:

gm(path)
.resize(w开发者_如何学运维idth, height)
.crop(50, 50, left, top)
.write(path, function(err){})

It's very simple. I have no idea how to use canvas, what's the equivalent in canvas?

Thanks.


For some reason, this signature is never used in examples:

context.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh);
  • img = the image element
  • sx = source x
  • sy = source y
  • sw = source width
  • sh = source height
  • dx = destination x
  • dy = destination y
  • dw = destination width
  • dh = destination height

Crop using sx, sy, sw, sh

Resize using dw, dh

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜