Page 1 of 1

Inner border

Posted: 2017-04-20T07:15:19-07:00
by josephs
Hi.

Is there a quick way to add an inner border to an image? I have been using -border, but as expected it adds the border outside of the image creating a larger image.

Any help is appreciated.

Re: Inner border

Posted: 2017-04-20T07:50:33-07:00
by snibgo
You can shave pixels from the edges before adding the border. See http://www.imagemagick.org/script/comma ... .php#shave

Re: Inner border

Posted: 2017-04-20T07:58:55-07:00
by josephs
Just what I was looking for. Thank you!

Re: Inner border

Posted: 2017-04-20T08:09:37-07:00
by GeeMack
josephs wrote: 2017-04-20T07:15:19-07:00Is there a quick way to add an inner border to an image? I have been using -border, but as expected it adds the border outside of the image creating a larger image.
Yep, as snibgo mentioned, you can shave off a given amount of the image, then add a border of that same amount. In its simplest form, to get an inner border of 6 pixels for example, you could put something like this into your command...

Code: Select all

... -shave 6 -border 6 ...
Of course you can make the horizontal borders different widths than the vertical borders with "-shave WxH -border WxH". You can also work all those borders separately by applying "-chop" and "-splice" operations. It's just about the same, but you'll have to make sure your gravity settings are correct for each operation.

Re: Inner border

Posted: 2017-04-20T08:16:27-07:00
by josephs
Yup nice and simple. Works.

Re: Inner border

Posted: 2017-04-20T08:45:41-07:00
by snibgo
It is simple, and quick to write. It probably isn't the quickest to execute. It may be quicker to draw four rectangles of the required size, one per edge, especially if the image is large but the border is thin.