Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composite another image, but with margin/padding

Tags:

imagemagick

I am currently doing the following to overlay a large image onto another:

$ convert orig.png overlay.png -gravity center -composite new.png

overlay.png is large and really just a semi-transparent texture.

But in some cases I'd like to have a 1 pixel sized margin around the overlay. So:

+--------------+
|  +--------+  |
|  | Overlay|  |
|  +--------+  |
+--------------+

Is this possible?

like image 557
t9mike Avatar asked Oct 12 '25 15:10

t9mike


1 Answers

Yes it is, for example you can add a border to overlay.png image and then compose the result with orig.png image.

To add a white 1px margin you can use these commands:

convert overlay.png -bordercolor White -border 1x1 overlay_border.png
convert orig.png overlay_border.png -gravity center -composite new.png
like image 127
Andrea Avatar answered Oct 15 '25 04:10

Andrea