You will have to convert from cm or inches to pixels using the image's density (nominally 72 dpi, but it may be different). Then you can simply use -bordercolor white -border X, where X is in pixels (see
http://www.imagemagick.org/Usage/crop/#border), if you want it uniform all around. If you want different borders, then use -splice (see
http://www.imagemagick.org/Usage/crop/#splice)
You can find the density or resolution and units for an image from string formats %x and %y from
http://www.imagemagick.org/script/escape.php
convert -units pixelsperinch zelda3.png -density 72 zelda3.pnm
convert zelda3.pnm -format "%x x %y" info:
72 Undefined x 72 Undefined
Does PNM format support units?
You would then convert 72 dpi (presumably) to centimeters and then figure out how many pixels that means for a 2 cm border.
Here is an example:
# create test image:
convert zelda3.jpg -density 72 -units pixelsperinch zelda3_72dpi.jpg
# process it to add a 2 cm border
borderwidth=2 #assume centimeters
res=`convert zelda3_72dpi.jpg -format "%x" info:`
density=`echo "$res" | cut -d\ -f1`
units=`echo "$res" | cut -d\ -f2`
echo "density=$density; units=$units"
if [ "$units" = "PixelsPerCentimeter" ]; then
borderpix=`convert xc: -format "%[fx:2*$density]" info:`
elif [ "$units" = "PixelsPerInch" -o "$units" = "Undefined" ]; then
borderpix=`convert xc: -format "%[fx:round(2*$density/2.54)]" info:`
fi
echo "borderpix=$borderpix"
convert zelda3_72dpi.jpg -bordercolor white -border $borderpix zelda3_72dpi_border.jpg