Jesper
3rd of July 2004 (Sat), 13:16
Recently (http://photography-on-the.net/forum/showthread.php?t=36230) someone asked for a way to resize lots of images to a certain fixed size on the long end. I posted my "Prepare for Web" script, which I use to prepare my photos for publishing on the web.
My script had one flaw: it always resized photos to 720 x 480 (or 480 x 720), stretching the width / height ratio if it wasn't 3 : 2.
Here's a new version of my script which keeps the width / height ratio intact. This is what the script does:
1. Flattens the currently active document (i.e. combines all layers).
2. Converts the image to the sRGB colour space if necessary.
3. Converts the image to 8 bits per channel if necessary.
4. Resizes the image so that the longest side will be 720 pixels wide or high.
How to use it: The script is written in JavaScript. With a text editor (Notepad, for example) save it somewhere on your hard drive with the extension ".js". In Photoshop, choose File / Scripts / Browse and navigate to the file. You can also put the script in the folder C:\Program Files\Adobe\Photoshop CS\Presets\Scripts. If you do that, the script will appear in the File / Scripts menu the next time you start Photoshop.
Have fun...
// Prepare for Web script for Photoshop CS
// Copyright (C) 2004, Jesper de Jong (jespdj@hotmail.com)
var targetSize = 720
doc = app.activeDocument
doc.flatten()
if (doc.colorProfileName.substring(0,4) != "sRGB")
doc.convertProfile("sRGB IEC61966-2.1", Intent.PERCEPTUAL, true, false)
if (doc.bitsPerChannel != BitsPerChannelType.EIGHT)
doc.bitsPerChannel = BitsPerChannelType.EIGHT
var startRulerUnits = app.preferences.rulerUnits
app.preferences.rulerUnits = Units.PIXELS
if (doc.width > doc.height) {
doc.resizeImage(targetSize, doc.height * targetSize / doc.width, doc.resolution, ResampleMethod.BICUBIC)
}
else {
doc.resizeImage(doc.width * targetSize / doc.height, targetSize, doc.resolution, ResampleMethod.BICUBIC)
}
app.preferences.rulerUnits = startRulerUnits
My script had one flaw: it always resized photos to 720 x 480 (or 480 x 720), stretching the width / height ratio if it wasn't 3 : 2.
Here's a new version of my script which keeps the width / height ratio intact. This is what the script does:
1. Flattens the currently active document (i.e. combines all layers).
2. Converts the image to the sRGB colour space if necessary.
3. Converts the image to 8 bits per channel if necessary.
4. Resizes the image so that the longest side will be 720 pixels wide or high.
How to use it: The script is written in JavaScript. With a text editor (Notepad, for example) save it somewhere on your hard drive with the extension ".js". In Photoshop, choose File / Scripts / Browse and navigate to the file. You can also put the script in the folder C:\Program Files\Adobe\Photoshop CS\Presets\Scripts. If you do that, the script will appear in the File / Scripts menu the next time you start Photoshop.
Have fun...
// Prepare for Web script for Photoshop CS
// Copyright (C) 2004, Jesper de Jong (jespdj@hotmail.com)
var targetSize = 720
doc = app.activeDocument
doc.flatten()
if (doc.colorProfileName.substring(0,4) != "sRGB")
doc.convertProfile("sRGB IEC61966-2.1", Intent.PERCEPTUAL, true, false)
if (doc.bitsPerChannel != BitsPerChannelType.EIGHT)
doc.bitsPerChannel = BitsPerChannelType.EIGHT
var startRulerUnits = app.preferences.rulerUnits
app.preferences.rulerUnits = Units.PIXELS
if (doc.width > doc.height) {
doc.resizeImage(targetSize, doc.height * targetSize / doc.width, doc.resolution, ResampleMethod.BICUBIC)
}
else {
doc.resizeImage(doc.width * targetSize / doc.height, targetSize, doc.resolution, ResampleMethod.BICUBIC)
}
app.preferences.rulerUnits = startRulerUnits