Batch Web Images

Script for Adobe Photoshop

The script reads a folder of images and outputs JPG or PNG copies suitable for web use. While processing, backgrounds may be removed based on a path, alpha channel, or using the Photoshop Select Subject feature. When removing backgrounds, the script can also crop the image tighter to the subject. Pixels dimensions may be limited to keep file size manageable.

  • Convert folder of images to JPG or PNG
  • Remove background
  • Crop in on subject
  • Limit pixel dimensions
Get more features
Batch Size And Mask
Download
Batch Web Images
Help me keep making new scripts by supporting my work. Click the PayPal button to contribute any amount you choose. Thank you. William Campbell

IMPORTANT: the script depends on the Photoshop feature Select Subject that was introduced in Photoshop CC 2018 (version 19). Earlier versions of Photoshop will not run this script correctly. For best results use the latest version of Photoshop as the Select Subject feature has improved greatly in recent years.

How-to Video

How to use the script

The interface has three sections: Input, Options, and Output. Set desired options and click the OK button to begin. A progress bar is displayed as images are processed. Each image is flattened and converted to 8-bit sRGB color (web standard). Then images are transformed per the options chosen, and resolution is set (not resampled) to 72 pixels per inch. The result is copied to a new document so excess information from the original is omitted (metadata, EXIF, etc.). Then the image is saved in the chosen format to the selected location. If Include subfolders is enabled, the subfolder structure is preserved in the output folder. If problems are encountered, a log file is written to the output folder, and the user is notified.

The script depends on the accuracy of Photoshop’s Select Subject feature, which works well in most cases, but isn’t perfect 100% of the time. At a minimum, the user should open Bridge and scan through thumbnails of images output to ensure the results are satisfactory. For any images that fail to mask the subject correctly, open in Photoshop and mask the subject manually.

As of Photoshop version 23.5.0, Select Subject added the options Device (Quicker results) and Cloud (Detailed results). For most installations the default is Device, the only choice prior to version 23.5.0. The script uses whatever is the default method. To change the default method to the superior Cloud option, go to Preferences (Windows) or Settings (macOS), section Image Processing. Set the drop-down list Select Subject Processing to the desired default method.

Section 1: Input

Folder — select a folder of images to convert.

Include subfolders — if enabled, images in subfolders are included. All subfolders in the input folder are created in the output folder so the subfolder structure is preserved.

Section 2: Options

Remove background — enable the checkbox and the script attempts to remove the background using the options next.

Path — the first path found is used to mask the image. If a path isn’t found, the script uses Select Subject instead.

Alpha channel — the first alpha channel found is used to mask the image. If an alpha channel isn’t found, the script uses Select Subject instead.

Select subject — the scripts uses Photoshop Select Subject to mask the image. The results depend on Photoshop’s ability to detect a subject. If Photoshop has trouble accurately masking an image, the script suffers the same.

Crop — when enabled, enter a percentage of the subject’s longest dimension to use as margins around the subject. Image area beyond the margins is removed, but margin is not added where it would exceed the original boundaries of the image.

Maximum pixels, width and height — enable the checkbox to limit the final pixel dimensions of the image, and enter a value in pixels for the width and/or height. It is acceptable to omit one of the dimensions. In that case, the entered dimension is limited and the other falls wherever it may. When both values are entered, neither dimension exceeds the value entered. One dimension may result in fewer pixels than entered if necessary to maintain proportions. In other words, setting both values does not define precise width and height; it only defines the upper limit of each dimension.

It is HIGHLY RECOMMENDED this option is used. Few website visitors view on screens exceeding HD resolution, 1920x1080 pixels. Most view on phones of far less pixel resolution. Website images exceeding HD resolution slow down page loading and give visitors good cause to click away to another site. Nothing is gained by the extra resolution as the browser down-samples images anyway. In most cases the default limit 1200x800 is a good choice that maintains quality without excessive file size.

Section 3: Output

Folder — select a folder to which converted copies of images are saved.

Format — choose JPG or PNG. JPGs are flattened, making any background removed become white. PNG retains transparency so when backgrounds are removed the area becomes transparent.

Original file name + — a suffix of characters appended to each output file name. The characters entered must be legal to use in file names. Any illegal characters are automatically removed. Having no suffix is allowed, in which case output file names exactly match input file names.

Rename for web — detects characters in the file name that require URL encoding and replaces them with a dash. Prevents URLs that look like “…/This%20is%20the%20File%20Name.jpg”. Instead the result is “…/This-is-the-File-Name.jpg”.

File name lowercase — converts the output file name to lowercase. Recommended for web resource file names. While the domain name of URLs is case-insensitive, the path is not. However, some hosts convert paths to lowercase, causing resource not found when letter case doesn't match. Using lowercase for web resources helps avoid these errors.

When files are output, any existing files of the same name in the output folder are replaced without alert.

Help me keep making new scripts by supporting my work. Click the PayPal button to contribute any amount you choose. Thank you. William Campbell
Download
Batch Web Images

For help installing scripts, see How to Install and Use Scripts in Adobe Creative Cloud Applications.

IMPORTANT: scripts are developed for the latest Adobe Creative Cloud applications. Many scripts work in CC 2018 and later, even some as far back as CS6, but may not perform as expected, or run at all, when used in versions prior to 2018. Photoshop features Select Subject and Preserve Details 2.0 definitely fail prior to CC 2018 (version 19) as the features do not exist in earlier versions. For best results use the latest versions of Adobe Creative Cloud applications.

IMPORTANT: by downloading any of the scripts on this page you agree that the software is provided without any warranty, express or implied. USE AT YOUR OWN RISK. Always make backups of important data.

IMPORTANT: fees paid for software products are the purchase of a non-exclusive license to use the software product and do not grant the purchaser any degree of ownership of the software code. Author of the intellectual property and copyright holder William Campbell retains 100% ownership of all code used in all software products regardless of the inspiration for the software product design or functionality.