Original Images & Desired Outcome
I have a batch of PNG images which need the same automated image processing:
- Middle part (red) shall get eliminated entirely and its void filled from above/below
- Top (blue) and middle part (red) always have the same height
- The bottom part (green) may vary in height

How do I achieve this with a free script-able image processing suite?
- Such as ImageMagic or sips
ImageMagick -chop does just that
Man page on -chop:
Also handy is the counterpart function -splice:
Chop out the undesired red row
convert in.png -chop x92+0+50 out-chopped.pngin.pngis the original imageout-chopped.pngis the desired outcome-chop x92+0+50: From the default reference point top left (could be changed with -gravity) at x +0px and y +50px (after the top blue part we want to keep) chop out the red segment at full width (because no number is specified before thexand hence it assumes full canvas width) and at a height of 92px (had some seam, hence I added 2px to cut clean)Chop out the undesired red part + insert a thin separator row
If you want to insert some separator where you chopped out, you can achieve that with
-splice.convert in.png -chop x92+0+50 -background black -splice x2+0+50 out-chopped-spliced-separator.png-chopalready explained above-backgroundtoblackwhich applies to all later command in the queue.-splice x2+0+50From the default reference point top-left at X 0px and Y 50px splice in a row of full width (nothin specified in front of thex) and of 2px height. Because we have set the background color black in the previous step that 2px row is filled black.Batch processing
mogrifykeeps the same filename of each input file for the corresponding output file. Normally it overwrites in place. But we use:-pathto write the out files to target directory../batch-done*to consider all files of your current directory via shell globbing as the input files of your batch.Sources