I have a series of png-images (actually they are taken from an mp4-file).

I want to crop the same region from all the images I have taken.

What tool is best for that, such that I can define the region first and then crop all the png images to the same region of interest.

Is there something to batch compress the resultant images (lossless)?

I tried apngasm, unfortunately the details to be shown in the series get optimized away - although apngasm is said to work lossless!

Since all the resultant images have great similarity: What is the best way to zip them to minimum size such that they can easily appended to an email such that the other person can look at them step by step to discuss the detail I want to show in them.

3 Answers 3


You could use convert from package imagemagick:

$ convert image_in.jpg -crop <widthxheight+left+top> image_out.jpg

Then you could wrap that command in a for loop, with file pattern matching, etc.


A more complete version of the given answer:

Take Gimp and use its function Crop to determine the area you want to keep. Select the area from the bottom right to the top left such that the coordinates of the upper left point and the width and height are displayed in Gimp's status bar.

In my example it said at the bottom

316,88, ...px... Rectangle 1622x634 ...

I then wrote a script and made it executable:


# Variablendefinition
inputdir="/home/a/tmp/png"     # ~ did not work here instead of /home/a

# Abarbeiten der eingelesenen Bilder mit Hilfe einer For-Schleife
# und dem Programm ImageMagick.

for pic in "$inputdir"/v*.png ; do 
    picname=$(basename "$pic")          # siehe Ausgaben in eine Variable schreiben
    echo "Bearbeite Bild:    $picname"
    convert "$pic" -crop 1622x634+316+88 "$outputdir/$picname"

and that used this script which performed my cropping task.

I am still looking for an answer of a good compression taking into account that there are only small changes from one picture to the next one.


For doing image series in parallel (I would recommend only on SSD drive), install imagemagick and parallel (sudo apt install imagemagick parallel) and then try this:

mkdir out
parallel -j 4 convert {} -crop 2048x2048+0+0 out/{} ::: img-*.png

it uses 4 processes -j 4 to convert file {} into out/{} if file matches mask img-*.png

mogrify from imagemagick package may work as well.

Regarding to similarity and compression, the most efficient is to use uncompressed images and compress them with something that does not compress individual files, but everything together. p7zip is usually the best and tar+bzip2 are sometimes/rarely better (usually for text and data like images that have very low contrast) tar+xz is very similar to p7zip (the same compression, different metadata). However for the most people zip is by far the most convenient format. For technical people using Windows 7zip is ok and I would advice using tar only if recepient is familiar with Linux.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .