Page 1 of 1

border color

Posted: 2009-10-03T14:31:05-07:00
by mathfeel
Hi,

I am writing a script to pad the file I have with a border so that the final size is close to a square. I would like to be able to sample a pixel on the border (edge pixel?) of the existing file and use that as argument to -bordercolor. Reading through the documentation, I did not find anything about how to do such sampling. Anyone?

Thanks,

--Z

Re: border color

Posted: 2009-10-03T15:50:40-07:00
by fmw42
You need to do that in two command lines. First command line to get the color and save as a variable. Second command line to use the variable for your bordercolor.

color=`convert image -format "%[pixel:s.p{X,Y}]" info:`
convert image -bordercolor $color -border XX,YY resultimage

X,Y is the pixel location to sample to get the color

XX,YY is the pad in X and Y direction

see FX escapes at http://www.imagemagick.org/Usage/transform/#fx_escapes

see -border at http://www.imagemagick.org/Usage/crop/#border