Print this page

Batch Photo Resize - Powershell v3 Script for Windows


A lot of times our customers struggle with resizing images so that they can properly upload them to Magento products. Sometimes their suppliers give them either too big or uneven photos making it hard to them to produce a good result. Usually we can ask Magento to resize the images before serving them to the visitors however we believe it’s better to upload images in the correct size in the first place.

So we decided to write a small powershell script that will automatically resize all images in a folder to 1000 x 1000 px. This is a reasonable dimension for a website’s product images for most cases unless you require really high resolution zooming to view textures and other details.


In order For this script to work you need to install the following prerequisites if you don’t already have them

  1. Powershell v3 +
    If you have windows 10 you have powershell v3 but if you have older windows you might need to upgrade it from Microsoft’s website.
  2. ImageMagick Library
    This script uses the ImageMagick library to resize the images so it needs to be installed in your system. If you’re using make sure you download the correct Library version depending on your windows architecture (32bit, 64bit) from the official website.
  3. Notepad or similar text editor

You can download ImageMagick here.


The script doesn’t need any special installation. Just download it here, rename it to resizer.ps1 and then copy it to the directory where the images you want to resize are.

How to use

Copy the script “resize.ps1” to the folder containing the images you want to resize. Right click the file “resize.ps1” and click on “Run with Powershell”. The script will automatically resize all photos in that folder and put them in a subfolder called “resized”. The script is non-destructive and your old photos will remain untouched.

Run resize script with PowerShell

1.    Run with PowerShell

Adjusting dimensions for output images

By default the script will adjust the image canvas size to have a 1000x1000 px size and will add white background to the canvas to make them so. If you want you can alter the sizes by editing the script using notepad and

In line 19:

magick "$oldPath" -resize 1000x1000 -background white -gravity center -extent 1000x1000 "$newPath"

change “1000x1000” to your desired dimension
If your images have black background, you can also change the parameter

“-background white”


“-background black”

to add black color to the canvas instead of white.

Rate this item
(2 votes)

Social Share

Download attachments:

Related items

1 comment