Joel's Thoughts

Useful Imagemagick Commands For Dealing With Batch Of Images In Windows

February 22, 2017

On my latest freelance project, I was dealing with a lot of image manipulation. I used Imagemagick to quickly manipulate image size, background color, and even optimization for the web. This article assumes you’re using Windows and you installed Imagemagick inside C:\Program Files\ImageMagick-7.0.4-Q16\.

Here are some of the most useful commands I used as a Frontend Developer.

  1. Batch command conversion of .jpg files to .png:

        FOR /R %a IN (*.jpg) DO "C:\Program Files\ImageMagick-7.0.4-Q16\magick.exe" "%~a" "%~dpna.png"
    
  2. Batch command on resizing .jpg images to a specific size(480X384) and storing them in the “catalog” folder.

        FOR %G IN (*.jpg) DO "C:\Program Files\ImageMagick-7.0.4-Q16\magick.exe" %G -thumbnail 480X384 -sharpen 0 catalogs\%G
    
  3. Batch command to create thumbnail versions of .jpg images and optimize for the web then saved into “catalog” folder.

        FOR %G IN (*.jpg) DO "C:\Program Files\ImageMagick-7.0.4-Q16\magick.exe" %G -thumbnail 480X384 -sharpen 0 catalogs\%G
    
  4. Without creating a new image file, just optimize the batch of images inside the folder.

        FOR %G IN (*.jpg) DO "C:\Program Files\ImageMagick-7.0.4-Q16\magick.exe" %G -strip -quality 86 %G
    
  5. Remove a specific image background color(#c7c6cb) and saved them inside “batch” folder. It’s important to note that you need to know the background color inorder for this to work.

        FOR %G IN (*.jpg) DO "C:\Program Files\ImageMagick-7.0.4-Q16\magick.exe" %G -transparent #c7c6cb batch\%G
    


Hope these commands help you in painlessly dealing with batch of images.









  • About
  • Search
  • Resume
  • Powered by Jekyll using the Trio theme