Imagemagick skew image with 4 (x,y) coordinates

2020-07-29 06:05发布

I have 4 (x,y) coordinates between which I want place image as example given below.

The whole image must be placed within this area without cropping.

enter image description here

enter image description here

1条回答
在下西门庆
2楼-- · 2020-07-29 06:26

Using this 800x600 balloon:

enter image description here

You can use a "Perspective Distort" like this:

convert balloon.jpg -matte -virtual-pixel transparent  \
  -distort Perspective '0,0,50,0 0,599,100,599 800,0,750,100 800,600,500,500' result.png

There are basically 4 pairs of points in the parameters,i.e.

Pt1X,Pt1Y,Pt1NewX,Pt1NewY Pt2X,Pt2Y,Pt2NewX,Pt2NewY Pt3X,Pt3Y,Pt3NewX,Pt3NewY Pt4X,Pt4Y,Pt4NewX,Pt4NewY

So the command above moves point 0,0 to 50,0 and moves point 0,599 to 100,599 and so on.

enter image description here

I have labelled each of the points in red and drawn the path along which each one has moved in green.

查看更多
登录 后发表回答