Imagemagick内联边框,无需调整原始图像的大小

时间:2018-04-03 03:30:01

标签: image-processing image-manipulation imagemagick-convert

我尝试使用以下代码为尺寸为200x200像素的图像添加边框。

convert -border 2x2 -bordercolor "#cccccc" old.png new.png

上面的代码广告是一个2像素边框围绕 the old.png。因此,图像会扩展到204x204像素。

但是,我想添加内嵌边框。我对旧图像的边框重叠边缘部分没有任何问题。因此,新图像应该能够保持200x200像素的尺寸。请告知如何做到这一点。

1 个答案:

答案 0 :(得分:2)

您需要在周围剃除两个像素,然后添加两个像素边框。你应该尝试使用Imagemagick 6.如果使用Imagemagick 7,请用magick替换convert。

convert old.png -shave 2x2 -bordercolor "#cccccc" -border 2 new.png