Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 395
Shan Avatar asked Mar 23 '15 14:03

Shan


3 Answers

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
like image 113
Mark Setchell Avatar answered Sep 21 '22 06:09

Mark Setchell


find or xargs come to mind, eg.

find . -name \*.jpg -exec mogrify '{}' -resize 100x100 \;

Cheers,

like image 28
Anders R. Bystrup Avatar answered Sep 17 '22 06:09

Anders R. Bystrup


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 use mogrify -resize 50% "*.jpg"

Your case would be

mogrify -resize 100x100 "*.jpg"
like image 45
Ax_ Avatar answered Sep 19 '22 06:09

Ax_