Adding Borders

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Adding Borders

Post by helloworld »

I am trying to add a black border to an image, Below are the original images and borders added to Horizontal, Vertical and Square images,

http://f.cl.ly/items/0P353a1K3P1Z1E2V2O ... antal1.jpg
http://f.cl.ly/items/2D1Q2N0e0y3g2Z1M0M ... lfinal.jpg
http://f.cl.ly/items/070r0S0C2E3T023L120v/Square1.jpg
http://f.cl.ly/items/34260C1m0b0F0f2h02 ... efinal.jpg
http://f.cl.ly/items/1Y1C1r3N1K3j441x2W1M/Vertical1.jpg
http://f.cl.ly/items/2g3T2m313B2b3p3H1K ... lfinal.jpg

Command Used is,

convert Horizantal1.jpg -bordercolor black -border 10%x10% Horizantalfinal
convert Vertical11.jpg -bordercolor black -border 10%x10% Verticalfinal
convert Square11.jpg -bordercolor black -border 10%x10% Squarelfinal


If you notice in all the three images there is difference,

In Horizontal Image, Sides has more border than the top and bottom.
In Vertical Image, Top and bottom has more border than the sides
and square also in the same way.

What i have to do to make all the sides of border look equal in all the three orientations?

and what is the standard percentage of border i have to take 10x10 or more/less?
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: Adding Borders

Post by helloworld »

I am trying to apply three different types of border to an image. The border format look like below,

http://f.cl.ly/items/0G1l3Z1c2A0w1r290C3I/keyline.png
http://f.cl.ly/items/1C1w07181g0a0B3X1z ... eyline.png
http://f.cl.ly/items/101d1p2x3v3R3C0b2e3q/gallery.png

My question is how can i apply such kind of borders to an image when it is varying according to image size?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Adding Borders

Post by Bonzo »

First thing I would do is check the OPTIONS page to see how to correctly write what I wanted to do.

Depends on the version you are using as well.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Adding Borders

Post by fmw42 »

What i have to do to make all the sides of border look equal in all the three orientations?
Borders in percent are always measure relative to the image size. That is what percent means --- percent of width and percent of height.

As of IM 6.7.8-8, you can specify the same amount for both width and height based upon one or the other via either value-x % of width is added to left/right and to top/bottom or value-y % of height is added to top/bottom and to left/right.

The alternate is to just use pixels.

Please read the options page for -border at http://www.imagemagick.org/script/comma ... php#border

An alternate is to use -extent and specify the output size you want the borders to achieve after they have been added.

You can also specify different borders in width and height by using -splice.

see
http://www.imagemagick.org/Usage/crop/#splice

P.S. All these kind of questions should be addressed to the User's forum in the future.
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: Adding Borders

Post by helloworld »

Thanks a lot. it fixed my problem.
helloworld
Posts: 69
Joined: 2013-05-22T09:42:33-07:00
Authentication code: 6789

Re: Adding Borders

Post by helloworld »

I am trying to apply two different types of border to an image. The border format look like below,
My question is how can i apply such kind of borders to an image when it is varying according to image size?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Adding Borders

Post by fmw42 »

Please clarify your question. I do not see the relationship between the two borders other than one is thicker than the other. Your examples do not give enough information.

Note, you can chain the border options in the same command.

convert image -bordercolor black -border 20 -bordercolor white -border 1 result
Post Reply