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
border color
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: border color
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
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