'using mogrify on lot of images gives error
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
Solution 1:[1]
find
or xargs
come to mind, eg.
find . -name \*.jpg -exec mogrify '{}' -resize 100x100 \;
Cheers,
Solution 2:[2]
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
Solution 3:[3]
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"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Anders R. Bystrup |
Solution 2 | malat |
Solution 3 |