Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reduce image size using imagemagick for batch of images

I need to convert batch of .jpg images filesize using image magick. am able to convert a single file using the following code

  convert -strip -interlace Plane -gaussian-blur 0.05 -quality 65% 1.jpg result.jpg

I need to do this convert for a batch of images. i tried this but it is not working

   mogrify -path \images-rep  -strip -interlace Plane -gaussian-blur 0.05 -quality 66% *.jpg
like image 946
Dhinakar Avatar asked Jul 25 '14 07:07

Dhinakar


People also ask

How do I resize an image in ImageMagick?

To resize an image to specific dimensions, use the convert command with an input file, the -resize parameter, your preferred dimensions, and an output filename: convert original. png -resize 100x100 new. png.


2 Answers

Use this command to convert your batch of images under a folder

   mogrify -path imagepath  -strip -quality 50% *.jpg
like image 79
Prasath Bala Avatar answered Oct 24 '22 11:10

Prasath Bala


To specify a maximum file size, mogrify -define jpeg:extent=300kb *.jpg. However, this can be much slower than just -quality 50% and/or -resize 50%. https://stackoverflow.com/a/11920384/2097284

like image 30
Camille Goudeseune Avatar answered Oct 24 '22 11:10

Camille Goudeseune