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.
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"
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
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
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
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.