The Stack Overflow podcast is back! Listen to an interview with our new CEO.
    Post Made Community Wiki by don_crissti
1
source | link

You can do that with the help of the -draw operator:

convert in.png -fill none -stroke black -strokewidth ${WIDTH} -draw "rectangle ${X1},${Y1} ${X2},${Y2}" out.png

where: WIDTH - stroke width
X1 - x coordinate of the top left corner
Y1 - y coordinate of the top left corner
X2 - x coordinate of the bottom right corner
Y2 - y coordinate of the bottom right corner

So e.g. for your other image that you want to crop+resize+convert to PDF you could run:

convert out.png -resize 2362x1630 -background white -gravity center -extent 2480x1748 \
-fill none -stroke black -strokewidth 10 -draw "rectangle 20,20 2460,1728" out.pdf