Automating the workflow for a publication does not always begin and end with a script targeted to Adobe InDesign. The need to involve another application can be as simple as working with the Finder. On the other hand, a script may become a little more involved if the functionality of an application such as Photoshop is required.
As an example, a publication I have been working with is using an internet provider to supply image content for its publication. The images are all the same size and do not need cropping. But, for the purpose of the publication, they need to be resized and saved as CMYK and JPEG. The workflow originally included bringing each of the five images into Photoshop manually, resizing, and then placing the images into an InDeisgn document. The images are stacked vertically from the bottom left of the page. The layout design required that the images have a space (gap) of 12 points between.
This is not a lot of work for one or two images, but when multiplied by many images and many editions, the task was becoming a good candidate for an automation script.
Creating the script using AppleScript was the immediate answer since only Macintosh is being used. Also, because applications in AppleScript are called within the script (using a tell statement), a single script could be used that would first activate Photoshop and later, once the images were saved in the appropriate folder, InDesign would take over.
The workflow would expect a pre-defined folder to exist and the target InDesign document to be open when the script is run. Also, the original images for manipulation and placement would be in the Downloads folder for the user. The outline for the script is as follows:
Note: When resizing an image in Photoshop, if you want the resized image to keep its aspect ratio, set only one of its dimensions (width or height). If you set both dimensions the resulting image could end up distorted.
One potential problem that needs to be checked within the handler is the color mode of each file. A grayscale or bitmap image cannot be converted to CMYK, consequently that would raise an error. To check for this, the following is used after the file is opened:
—values for newWid and newRes are passed as part of the call to the handler tell application “Adobe Photoshop CC 2014” tell current document if not (mode is grayscale or mode is bitmap) then change mode to CMYK end if resize image width newWid resolution newRes resample method automatic end if end tell
Because this script was written for a specific purpose, values for variables such as the resized width of the images, save quality, file name extension, and gap between placed images were all defined at the top of the script. Should the script need to be used for a variety of situations, a custom dialog could be added with input values defaulting to the most used values.
The script was placed in the Scripts Panel folder for InDesign and given a keyboard shortcut. With the target document open in InDesign the keyboard shortcut is used to launch the script. The user then selects the images to be used from the source folder (Downloads folder). The script does the rest. The amazing thing for me is to see how quickly the computer can run through all of the code. For the client, well he was amazed to see the process completed in less than a minute where it used to take the better part of an hour to process and place the files.
You can check out the entire script, ResizeSaveJPEG, which can be downloaded from our AppleScript page. You may find some code in this script that you can adapt to automate one of your own workflow issues involving Photoshop.