In the task of resizing 30GiB worth of digital photos, I ran into
two problems challenges with Adobe Photoshop. The
following assumes a knowledge of recording actions and running
batches in Adobe Photoshop.
After learning this, forgetting this, and relearning it at least once more, I've decided to document it. The solutions are pretty simple.
Tackling the JPEG dialog is as simple as making sure you have a "Save As" event in your recorded action and setting "Override action save as commands" in the batch window. Even though the recorded action seems to want to save every file over the file you used to record the action, the Override compensates for that. -- It just works
Resizing based on the larger dimension requires conditional actions, which you simply can't record (as of CS2). Fortunately, Adobe added scripting support. To make the conditional resize, I've written the following script:
// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop
// in case we double clicked the file
app.bringToFront();
if (app.documents.length > 0) {
app.preferences.rulerUnits = Units.PIXELS;
var len=1920;
if (app.activeDocument.width > len || app.activeDocument.height > len) {
if (app.activeDocument.height == app.activeDocument.width) {
var h=len;
var w=len;
} else if (app.activeDocument.height > app.activeDocument.width) {
var h=len;
var w=app.activeDocument.width*len/app.activeDocument.height;
} else { //(app.activeDocument.height < app.activeDocument.width) {
var h=app.activeDocument.height*len/app.activeDocument.width;
var w=len;
}
app.activeDocument.resizeImage(w,h);
w=null;
h=null;
}
}
Pretty simple, right? All one needs to do is save that code as a .jsx file, set the number as desired, and call it when recording the action.
Oh, and don't forget to set your bit depth to 8 if you're cramming other filetypes down to JPEG.
No Comments Yet
Post the first comment...