this will get to the top left corner and bottom right corner: ulx=left, uly=top, brx=right, bry=bottom
convert 23hu8ic.jpg -trim 23hu8ic_crop.gif
width=`convert 23hu8ic_crop.gif -format "%w" info:`
height=`convert 23hu8ic_crop.gif -format "%h" info:`
ulx=`convert 23hu8ic_crop.gif -format "%X" info:`
uly=`convert 23hu8ic_crop.gif -format "%Y" info:`
brx=`convert 23hu8ic_crop.gif -format "%[fx:$ulx+$width-1]" info:`
bry=`convert 23hu8ic_crop.gif -format "%[fx:$uly+$height-1]" info:`
echo "ulx=$ulx; uly=$uly; brx=$brx; bry=$bry;"
ulx=+24; uly=+16; brx=143; bry=135;
see -trim and string formats at
http://www.imagemagick.org/script/escape.php
This is for unix. If you are on Windows, see
http://www.imagemagick.org/Usage/windows/