Script Package Resizing Images

I am looking for some help writing a script package to resize .jpg images.

I do not have much experience with batch scripts. But this task will be preformed on a Windows machine, so I thought that a script package might be a good way.

I am always interested in hearing alternative ideas and approaches, or being aware of elements that I did not think about.

The following are the main 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. 
+7
windows shell batch-file jpeg image-resizing
source share
4 answers
+4
source share

If you want to do this on the command line specifically, it is possible that you can automate it; the package does not have a specific command for processing images. You can code something in JScript or another language and run it from the command line, but why do it when there are already available tools for this task?

I recommend ImageMagick .

Get a portable Windows binary, then you can use magick.exe to do what you want quite easily. For example, to change the size (in half) of all png-images in folder 1 to folder 2:

 @echo off if not exist 2 md 2 for %%a in (1\*.png) do "path\to\magick.exe" -resize 50x50% "1\%~nxa" "2\%~nxa" 
+6
source share

Once you install ImageMagick for Windows , you can use the magick command line tool , for example

 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 system PATH variable and you point to existing or created destination folders (for example, mkdir 250x250/ 125x125/ in the above case).

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

+6
source share

you can check scale.bat , which can resize images without the need to install additional software - it uses only the built-in features of Windows:

 @echo off set "source_folder=c:\images" set "result_folder_1=c:\res1" set "result_folder_2=c:\res2" for %%a in ("%source_folder%\*jpg") do ( call scale.bat -source "%%~fa" -target "%result_folder_1%\%%~nxa" -max-height 250 -max-width 250 -keep-ratio no -force yes ) for %%a in ("%source_folder%\*jpg") do ( call scale.bat -source "%%~fa" -target "%result_folder_2%\%%~nxa" -max-height 125 -max-width 125 -keep-ratio no -force yes ) 

Also check this one out .

+4
source share

All Articles