t9mike
t9mike

Reputation: 1626

Composite another image, but with margin/padding

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?

Upvotes: 4

Views: 1704

Answers (1)

Andrea
Andrea

Reputation: 12375

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

Upvotes: 4

Related Questions