Nodejs按坐标进行图像裁剪 [英] Nodejs image crop by coordinates

查看:261
本文介绍了Nodejs按坐标进行图像裁剪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有方法可以在裁剪图像时给出x,y坐标。

Is there is way where we can give x, y coordinates while cropoing image.

目前我使用的是 Imagemagick

Currently what i am using is Imagemagick

im.crop({
    srcPath: upload_path+media_file_name,
    dstPath: upload_path+"thumb_"+media_file_name,
    width: 350,
    height: 210,
    quality: 1,
    gravity: 'Center'
}, function(err, stdout, stderr){

};

此代码正常运行,但我没有运气 x y coordinates。我想用于图像裁剪的以下输入

This code is working but i haven't got luck with x, y coordinates. The following input i want to use for image cropping

height:360
width:360
x:180
y:300


推荐答案

我不说节点,但你可以使用原始界面吗?它看起来像

I don't speak node, but can you use the raw interface? It'll look something like

im.convert(['inputimage.jpg','-crop','350x200+x+y','output.jpg'],
   function(...)

x y 输入您自己的数字。

put in your own numbers for x and y.

这篇关于Nodejs按坐标进行图像裁剪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆