I am using mogrify to resize the images in a directory using the following command
mogrify -resize 100x100 *.jpg
due to the huge number of images, I get the following error
/usr/bin/mogrify: Argument list too long
Any suggestions?
Thanks
Actually, the answer is surprisingly simple. Rather than having the shell expand the argument list (which it cannot cope with), let ImageMagick expand the list itself internally, by protecting the arguments from the shell with single quotes.
So, your command becomes:
mogrify -resize 100x100 '*.jpg'
If the built-in glob expression does not work for you (eg. special file ordering), you may also use the special character '@':
mogrify -resize 100x100 @my_jpegs.txt
find
or xargs
come to mind, eg.
find . -name \*.jpg -exec mogrify '{}' -resize 100x100 \;
Cheers,
magick said
Most shells limit the length of the command line. You can get around this by using ImageMagick filename globbing methods. So instead of
mogrify -resize 50% *.jpg
usemogrify -resize 50% "*.jpg"
Your case would be
mogrify -resize 100x100 "*.jpg"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With