You want to both crop and resize the image:
mogrify -crop 800x520+0+300 -resize 320x200 *.jpg
And yes, since you're pictures differ then you may have to adjust the crop parameters per image. With some scripting, you can programatically adjust these parameters however, for example, creating a bash script cut-resize.sh
as below, and running it with a file name argument, so cut-resize.sh testimage.jpg
:
#!/bin/bash
origX=`identify $1 | cut -d' ' -f3 | cut -dx -f1`
origY=`identify $1 | cut -d' ' -f3 | cut -dx -f2`
offset=300
eval "mogrify -crop ${origX}x$(($origY/2))+0+$offset -resize 320x200 $1"
Will do the nearly the same thing - cut the middle 50% of the image and then resize, for any sized image. You could add additional arguments and variables so you could specify your offset and the ammount to crop, but let your script take care of setting the geometry for imagemagick.
Or on windows, the following batch example might work, I have no idea, I only have a linux box, but the point is that you can script adjustment of the variables:
file=%1
rem identify %file% | cut -d' ' -f3 | cut -dx -f1
for /f "tokens=3" %%G IN ('identify %file%') DO set temp=%%G
for /f "tokens=1" "delims=x" %%G IN ("%temp%") DO set oldx=%%G
for /f "tokens=2" "delims=x" %%G IN ("%temp%") DO set oldy=%%G
offset=300
newx=%oldx%
newy=%oldy%/2
mogrify -crop %newx%x%newy%+0+%offset% -resize 320x200 %file%
A good reference for batch, bash or powershell scripting is http://ss64.com/. Combining scripting with Imagemagick is very powerful once you build out your workflows and scripts.