the @ approach may be too uncertain to use. You need to find the number of pixels you desire. Say 120x120=14400
convert hatching_orig.jpg -thumbnail "14400@" hatching_at.jpg
results in a size of 138 x103, but this may vary from image to image, I am not sure.
If you use
convert hatching_orig.jpg -thumbnail "120x120" hatching_at.jpg
you get a resulting size always of 120x90
or
convert hatching_orig.jpg -thumbnail "130x130" hatching_130x130.jpg
you get a resulting size of always 130x98
Your description of your desires seems to have changed or has not been very clear. I spent quite some time trying to get your result to 120x120 end size as you asked. Shadows will offset the image, so if that is not what you want, you will have make the image even smaller and then pad on the left and top to compensate for the shadow. I think you will have to work some more with what I gave you. I am not sure when I can get back to this as I have other commitments.
You misunderstand the examples given by Anthony, when you resize, it does not pad, it just keeps the aspect ratio. So if you use -thumbnail 130x130, it will resize to the larger dimension and then scale the smaller dimension. So the result will be 130x98 with no padding. If you want to "zoom" then you want to use -thumbnail "120x120^" which will make an image 160x120. Then you can crop to any smaller size, but you will lose some of the image.
So I am still not clear what you really want to have done here. I think you need to experiment your self with the various -resize or thumbnail geometries. See
http://www.imagemagick.org/script/comma ... p#geometry
If you can provide a more precise description of what you want, perhaps I can modify what I have provided for you.
Here is one more try with a black border so that it remains centered, rather than a shadow.
infile="hatching_orig.jpg"
size=130
size2=`convert $infile -define jpeg:size=${size}x${size} -thumbnail "${size}x${size}" -format "%wx%h" info:`
ww=`echo $size2 | cut -dx -f1`
hh=`echo $size2 | cut -dx -f2`
if [ $ww -ge $hh ]; then
xsize=120
ysize=$hh
lsize=120
else
xsize=$ww
ysize=120
lsize=120
fi
drawcmd=`convert $infile -define jpeg:size=${size}x${size} -thumbnail "${size}x${size}" -gravity center -crop ${xsize}x${ysize}+0+0 +repage \
-format "roundrectangle 1,1 %[fx:w-1],%[fx:h-1] 15,15" info:`
convert \( $infile -define jpeg:size=${newsize}x${newsize} -thumbnail "${size}x${size}" -gravity center -crop ${xsize}x${ysize}+0+0 +repage \) \
\( +clone -threshold "100%" -fill white -draw "$drawcmd" \) \
-alpha off -compose Copy_Opacity -composite \
\( +clone -alpha transparent -background none \
-fill none -stroke black -strokewidth 1 -draw "$drawcmd" \) \
-compose Over -composite -background none -gravity center -extent ${lsize}x${lsize} \
hatching_rounded_border.png
and if rotate input by 90
convert hatching_orig.jpg -rotate -90 hatching_orig_rot90.jpg
infile="hatching_orig_rot90.jpg"
size=130
size2=`convert $infile -define jpeg:size=${size}x${size} -thumbnail "${size}x${size}" -format "%wx%h" info:`
ww=`echo $size2 | cut -dx -f1`
hh=`echo $size2 | cut -dx -f2`
if [ $ww -ge $hh ]; then
xsize=120
ysize=$hh
lsize=120
else
xsize=$ww
ysize=120
lsize=120
fi
drawcmd=`convert $infile -define jpeg:size=${size}x${size} -thumbnail "${size}x${size}" -gravity center -crop ${xsize}x${ysize}+0+0 +repage \
-format "roundrectangle 1,1 %[fx:w-1],%[fx:h-1] 15,15" info:`
convert \( $infile -define jpeg:size=${newsize}x${newsize} -thumbnail "${size}x${size}" -gravity center -crop ${xsize}x${ysize}+0+0 +repage \) \
\( +clone -threshold "100%" -fill white -draw "$drawcmd" \) \
-alpha off -compose Copy_Opacity -composite \
\( +clone -alpha transparent -background none \
-fill none -stroke black -strokewidth 1 -draw "$drawcmd" \) \
-compose Over -composite -background none -gravity center -extent ${lsize}x${lsize} \
hatching_rot90_rounded_border.png