Photoshop Scripts

Batch Canvas and Image Resizer

I found myself in a situation where I needed to take hundreds of images and put white borders around them – either on the L/R sides or Top/Bottom – and make them all the same sizes. In my case, I needed to have the final images be a square rather than rectangular. Doing this manually within Photoshop would be tedious to say the least.

A quick web search turned up a couple scripts that did part of what I was needing to do, but none fully was up to the task. Again, it was a quick search. I started digging into the code that was in a couple scripts that I found and figured I could just make my own.

Resize Canvas dialog

Key Requirements

  1. Select a folder that contained 1-n images as the source
  2. Select a folder that the output would save the images
  3. Be able to input width and height dimensions in pixels
  4. Set the Anchor Position for resizing the canvas
  5. Set the Canvas Extension Color to white*.
  6. Adjust the output JPEG Quality Level.
  7. Quickly process the images in the Source folder.

* Currently, white is the default Canvas Extension Color. Plan is to incorporate options into the script interface for color selection.

Download the Script

About the Script

  • Source file types include:
    • JPEG/JPG
    • BMP
    • PSD
    • PNG
  • At this time, the script is not recursive into sub-folders within the Source Folder.
  • Destination Folder – You can select the same folder as the Source Folder. However, files will be overwritten without warning once the script has been executed.

Script Name

You may ask why the file name for the script is ‘Resize_to_1200x1200’ rather than something more descriptive of what the script does. Well, I initially needed something that would create a square with 1200×1200 dimensions and those dimensions were hard-coded into the script. As development progressed, I just kept the name.

Using the Script

To quickly run the script:

  1. Download the file to your local computer.
  2. Unzip the downloaded file.
  3. In Photoshop, File -> Scripts -> Browse…
  4. In the dialog box, navigate to the location where you unzipped the script and press Open.
  5. In the Resize Canvas window, fill out the different options and press the Okay button.
  6. When finished, you will be alerted indicating the number of images processed.

If you want to add the script to your Scripts menu and you are using a Mac:

  • From the Finder, press Shift+Command+G to bring up the ‘Go to the folder’ dialog.
  • Paste this path /Applications/Adobe Photoshop 2020/Presets/Scripts in the text field and press Go. Note you may need to change ‘Adobe Photoshop 2020’ to the correct folder name for your version.
  • Copy the Resize_to_1200x1200.js file to the folder you just opened.
  • Restart Photoshop
  • In Photoshop File -> Scripts -> Resize_to_1200x1200

Credits and Inspiration

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: