A Batch Script To Resize Images

Reed Williams picture Reed Williams · Nov 7, 2016 · Viewed 41.6k times · Source

I'm looking for some help in writing a batch script to resize a bunch of .jpg images.

I don't have much experience with batch scripts. But this task will be preformed on a windows machine & so I thought a batch script might be a good way to go.

I'm always interested in hearing alternative ideas & approaches, or being made aware of elements I haven't thought of.

Below I have listed the basic steps/needs of the script:

1) The images are located in a folder & are all(or should be) 500 x
500.

2) I need copy & past the images to a new folder, where they will be
resized to 250 x 250.

3) I then need to repeat step 2 but this time resize to 125 x 125.

Answer

kenorb picture kenorb · Sep 11, 2017

Once you install ImageMagick for Windows, you can use magick command-line tool, e.g.

magick.exe mogrify -resize 250x250 -path 250x250/ *.png *.jpg
magick.exe mogrify -resize 125x125 -path 125x125/ *.png *.jpg

Note: Make sure your magick.exe command is in your PATH system variable and you're pointing to the existing or created the destined folders (e.g. mkdir 250x250/ 125x125/ in above case).

For Linux/Ubuntu, see: How to easily resize images via command-line?