在图像顶部添加边框,而无需使用imagemagick调整大小 [英] add border on top of image without resizing with imagemagick

查看:50
本文介绍了在图像顶部添加边框,而无需使用imagemagick调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是乌龟的100x67像素图片:

如果我在图像上添加边框,如下所示:

 转换turtle.png-边框50x50 turtle-border.png 

ImageMagick在我的原始图像周围添加边框,将尺寸增加到200x167px.

如何在不调整尺寸的情况下在乌龟图像的顶部绘制边框?是的,我知道乌龟的头和脚不再可见.

解决方案

要创建在图像中吃"的边框,请使用在图像上放置一个矩形的操作.

  convert turtle.png-填充gray75 \-绘制'矩形0 0 100 33'\turtle-border.png 

Here is a 100x67px image of a turtle:

If I add a border to my image like so:

convert turtle.png -border 50x50 turtle-border.png

ImageMagick adds border around my original image, increasing the dimensions to 200x167px.

How do I paint a border on top of my turtle image without resizing the dimeions? Yes, I know the turtle's head and feet will no longer be visible.

解决方案

To create a border that's "eating" into the image, use -shave to reduce the image, then -extent it back to original size.

convert turtle.png -background gray75 \
        -shave 10x10 \
        -extent 100x67-10-10 \
        turtle-border2.png

Previous answer

Use the -draw operation to place a rectangle over the image.

convert turtle.png -fill gray75 \
        -draw 'rectangle 0 0 100 33' \
        turtle-border.png

这篇关于在图像顶部添加边框,而无需使用imagemagick调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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