开发者

Add border to top of image using imagemagick

开发者 https://www.devze.com 2022-12-20 18:40 出处:网络
I have an image 10开发者_如何学Python0x40 and I want to add a border to the top of the image 10 pixels high.

I have an image 10开发者_如何学Python0x40 and I want to add a border to the top of the image 10 pixels high.

I've found

convert source.jpg -border 0x10 out.jpg

but this adds a border to the top and bottom. Is there anyway to add it to only the top?


Use -splice:

convert source.jpg -splice 0x10 out.jpg

If you want to add the border only at the bottom, use -gravity as well: convert source.jpg -gravity south -splice 0x10 out.jpg

Note that the border will be transparent, unless you use -background, too.

See also Cutting and Bordering for more examples.


Use -extent instead:

convert source.jpg -gravity south -extent 100x50 out.jpg

-gravity tell it which direction to move the original image.

0

精彩评论

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

关注公众号