Page 1 of 1

Uneven border

Posted: 2008-08-21T20:45:04-07:00
by Zippo25
I'm looking for a simple Polaroid like picture effect... This would be taking the original image, and putting a white border around it outlined with a thin black line with more space at the bottom of the image to place a caption and other info.

The following command line, creates a nice simple photo look with an even border around it:

Code: Select all

convert input.jpg -bordercolor white -border 10x10 -bordercolor black -border 1x1 output.jpg
Example:

Image

Changing this to increase the y of the white border to give more space:

Code: Select all

convert input.jpg -bordercolor white -border 10x30 -bordercolor black -border 1x1 output.jpg
Adds more space top to bottom, but the image is centered top to bottom as well which is not what I am looking for.

Example:
Image

Is there a way to offset the image so that it is not centered top to bottom but rather has more space on the bottom?

Example:

Image

Re: Uneven border

Posted: 2008-08-21T22:13:11-07:00
by fmw42
see -extent http://www.imagemagick.org/Usage/crop/#extent

Do -border followed by -extent


You can also use -splice.

Or you can create a white image of the excess size you want and -append it at the bottom.
http://www.imagemagick.org/script/comma ... php#append

Re: Uneven border

Posted: 2008-08-21T22:53:07-07:00
by Zippo25
Hmmm ...

1) don't know the size of the image before hand... Can use identify to figure that out and then generate the output..

2) Version of ImageMagick is old enough to not have that command (-extent)... Not sure if I can get it upgraded.

Thanks...

Re: Uneven border

Posted: 2008-08-21T23:26:17-07:00
by fmw42
you can also create the output the size you want as a white background and overlay your image onto it at the top so that the excess white remains below.

consider 20 pixel border all around and another 50 pixels of white at the bottom:


Get the width and height using IM and add your border all using IM fx calculations and strings

convert <image> -bordercolor white -border 20 <tmpimage>
width=`convert <tmpimage> -format %w info:`
height=`convert <tmpimage> -format %h info:`
convert <tmpimage> \( -size ${width}x50 xc:white \) -append <newimage>

or

width=`convert <image> -format %w info:`
height=`convert <image> -format %h info:`
width2=`convert xc: -format "%[fx:$width+40]" info:`
height2=convert xc: -format "%[fx:$height+40+50]" info:`
convert \( -size ${width2}x${height2} xc:white \) \( <image> -bordercolor white -border 20 \) \
-gravity north -composite <newimage>

or

width=`convert <image> -format %w info:`
height=`convert <image> -format %h info:`
width2=`convert xc: -format "%[fx:$width+40]" info:`
height2=convert xc: -format "%[fx:$height+40+50]" info:`
convert \( -size ${width2}x${height2} xc:white \) <image> \
-geometry ${width2}x${height2}+20+20 -composite <newimage>

Re: Uneven border

Posted: 2008-08-21T23:42:19-07:00
by Zippo25
Cool... will give that a try. Of the 22 servers checked, 12 had older versions... weird.

Re: Uneven border

Posted: 2008-08-22T00:01:01-07:00
by Zippo25
This worked...

Code: Select all

convert source.jpg -bordercolor white -border 10x10 temp1.jpg
width=`identify temp1.jpg -format %w`
height=`identify temp1.jpg -format %h`
convert temp1.jpg -size ${width}x35 xc:white -append temp2.jpg
convert temp2.jpg -bordercolor black -border 1x1 output.jpg
Example:

Image

Thanks for pointing me in the right direction....

Re: Uneven border

Posted: 2008-08-22T08:53:21-07:00
by Bonzo
There is a poleroid method in later versions of ImageMagick: http://redux.imagemagick.org/script/com ... p#polaroid

Out of interest this is a method to make a row of images and in this case I am using php to also generate a type of "imagemap".
http://www.rubblewebs.co.uk/imagemagick ... _f_74.html
It is based on an example written by Anthony.