I read Using mogrify (imagemagick) to batch convert all my files (with params) and it seems my query/path is very similar, except the fact that all the pictures in my directory have same Width and Height.

[$] mediainfo 20160714_161847.jpg                                                                                               
Complete name                            : 20160714_161847.jpg
Format                                   : JPEG
File size                                : 2.66 MiB

Format                                   : JPEG
Width                                    : 4 128 pixels
Height                                   : 2 322 pixels
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Compression mode                         : Lossy
Stream size                              : 2.66 MiB (100%)

Now I would like to batch compress them to another directory altogether so the original/parent pictures are not touched. I do know that any compression would basically be taking information out of the picture and would have some artefacts.

Just to be more explicit, let's say the number of the directories are -

/home/shirish/input_directory/*.jpg - input_directory has all the .jpgs which need to be shrinked/trimmed so that they are ok for web-publishing.

/home/shirish/output_directory/ - This is where the manipulated pictures should end up being. The original pictures should not be touched at all and remain where they are.

A nice touch would be if there is a way to also see the progress of the manipulation as it goes through the pictures either with just as ASCII bar or preferably with telling how many number of images are done out of how many it is going to do along with the console/ascii bar.

What is intersting to note is that the sample image does not seem to have any gps information even though I am sure some of the images in the collection have that information. Is there also a way to search/grep through all the images to see if there is location-aware information (GPS co-ordinates) or something similar in the images.

Update - Just to share it worked - see -

 ~/Pictures/original$ mogrify -path /home/shirish/Pictures/reduced -monitor -quality 70 -trim -resize '>'600x480 *.jpg

    load image[asus-prime-Z270-p-lga1151-motherboard.jpg]: 1215 of 1216, 100% complete

    Resize/Image//home/shirish/Pictures/reduced[asus-prime-Z270-p-lga1151-motherboard.jpg]: 1052 of 1053, 100% complete

    Save/Image//home/shirish/Pictures/reduced[asus-prime-Z270-p-lga1151-motherboard.jpg]: 479 of 480, 100% complete

The only thing I don't know is from where does imagemagick get the numbering but that's for another day, another question altogether :)

  • what does it matter that your images all have the same width & height? The linked article still applies.
    – meuh
    Jul 20, 2016 at 9:41
  • Use convert instead of mogrify if you don't want to make changes in-place. Jul 20, 2016 at 9:42
  • could somebody share the command needed giving the inputs I have shared above as an answer. So I'll know what parameters need to be passed and how and what those parameters mean instead of just the command, so I could play around and get it right
    – shirish
    Jul 20, 2016 at 13:32

1 Answer 1


This is a minimal version of the commands to give to resize to width 600 height 400 (if greater than that), setting the jpeg quality to 70 (it is a percentage: a smaller number makes for less bytes but less quality).

cd /home/shirish/input_directory/
mogrify -path /home/shirish/output_directory/ -monitor   -quality 70  -trim  -resize '>'600x400 *.jpg

If there are too many files you may need to use find|xargs

  • I tried using convert and not mogrify as it was shared that convert is good if you do not want to do changes in-place, see above .
    – shirish
    Jul 20, 2016 at 13:43
  • hence did [$] convert -path /home/shirish/Pictures/output_directory/ -monitor -quality 70 -trim -resize '>'600x400 *.jpg convert: unrecognized option `-path' @ error/convert.c/ConvertImageCommand/2440. . As can be seen convert doesn't understand the -path part.
    – shirish
    Jul 20, 2016 at 13:44
  • Use mogrify with -path, as this says to not change the original file but put the copies in that directory. Read man mogrify. Try with a copy of some files first to test.
    – meuh
    Jul 20, 2016 at 13:52
  • I get this 'mogrify-im6.q16: unable to open image `/home/shirish/output_directory//pmc-1.jpg': No such file or directory @ error/blob.c/OpenBlob/2924.' '
    – shirish
    Apr 3, 2022 at 5:45

You must log in to answer this question.

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