Click on the link at the bottom of the page to return to Lazy Dogg’s Laziness Page.

A JavaScript script for Adobe Photoshop to set a limit on the image size.

Download the script.

This script is for making sure none of your Photoshop documents are bigger than a certain size in pixels.

Suppose you had a screen saver of all your pictures on a 1024 x 768 or 800 x 600 screen, but all your pictures were enormous 10 megapixel things. Screensavers can resize images to fit the screen, but can they do it as well as Photoshop? And asking your hard disk to load a few dozen megabytes every few seconds is going to slow things down and make the show a bit jerky, plus the disk light will be flashing all the time, and anything else you’re running in the background (like a defragmentation, download, script, virus checker) is going to be substantially slowed down.

SO, why not resize all your pics to fit on the screen? Yes but… what if some of your pictures are SMALLER than your screen: do you really want to blow up your 320x240 mobile phone pictures or teeny emailed pics from friends to 1024x768?!

This gem of laziness finds out how big each picture is, and ONLY RESIZES IT IF IT’S TOO BIG. And it doesn't mess up the aspect ratio either.

Note: I wrote this script in Photoshop CS and found it wasn’t working on Photoshop 7. To fix it, I had to edit the script and change "docRef.width.value" and "docRef.height.value" to "docRef.width" and "docRef.height".

How to use it

  1. First, you’ll need to download the script (right-click or control-click (for Mac users) the link below and choose "Save target as" (or similar).
  2. Open the file in a text editor and find the lines “var newX = ;” and “var newY = ;”. This is where you can choose the size in pixels that you want to limit your pictures to. Put in some numbers (remember, if you’re making images to go in a web brower on a 1024x768 screen, the amount of space available will be a lot less, because of the browser’s toolbars and scroll bars etc).
  3. Save the script, open Photoshop, open a document and run the script (this is somewhere in the File menu: it’s under “Automate” in Photoshop 7). Hey presto (hopefully): the script resizes the image (if required) to the same aspect ratio of the original.

How to do it automatically

So, even if this worked, it’s not saving you much time is it? Aha - here’s where you need to combine some other Photoshop features. First, make an Action that runs your script, then saves and closes the file. Then use Photoshop’s Automate feature to batch-run that Action on lots of files. It will zoom through whole folders full of files. Another triumph for laziness! Respect!!