Automated Image Placement

Before we leave the subject of InCopy Workflows, we need to discuss working with images. Image workflows are often mixed: sometimes the designer places images, while on other occasions this chore may be left to a member of the editorial staff. No matter who places the images, it is the designer’s responsibility as part of laying out the pages to include image containers and caption frames. To automate the process, a script may be used to create these items.

In InDesign

Creating Page Items for Image

Defining size and positioning for the image and caption page items can take on a life of their own. Consider the following:

  • Ad hoc: Designer draws a rectangle that looks about right, then places a text frame below it.These page items often end up on the same layer as an underlying text frame making them hard to select when in InCopy.
  • Stylebook: Another approach would be to set up a chart of specific image container sizes for both horizontal and vertical orientations based on their column width. This involves the user having to look up the size and fiddle with the frame to make sure the size is correct.
  • Automate it: The user places a rectangle to indicate page position and width and runs a script. The script presents the user with a drop box from which to choose the size ratio wanted for the image. From there the script calculates the size. This ratio list might include a number of common long-to-short-side ratios including the <b>golden ratio</b> (often called the golden mean). This ratio has long been believed to be most aesthetically pleasing. The golden ratio works out mathematically with the longer side being approximately 1.6 times the shorter side. Conversely, the shorter side would be .625 times the longer side. Other ratios may currently be in use by your organization. Once the measurements are calculated, the page items are created precisely on a layer reserved for images.

Adding Captions

One idea for automating images is to include the caption and credit as part of the image’s metadata (description and author fields). A script can then read the metadata and populate the caption frame as part of the process of placing the image.

Our sample script ImagePlaceholder has the user create a rectangle to indicate the placement and width of the image on the page. With the rectangle selected, the script is run using a keyboard shortcut. The script prompts the user to choose a file for placement. It then presents a simple dialog in which the user selects the size ratio for the image container, enters a name for the image, and indicates if the script should attempt to add contents to the text frame. It then creates the page items, names them using the name provided by the user, places the image, and adds credit and caption from the image’s metadata as needed.

If the designer decides to have the InCopy user place the image, the same script would be used only with a placeholder image and no caption. The image and caption frame are then included with the page item selection when the assignment script is run (AssignSelected).

In InCopy

The normal process for placing an image inside a container is to select the container and place the image. For InCopy, it is a little different, often causing concern with new users. Instead, let’s see how this could be automated.

Automating InCopy with scripts is similar to InDesign, but with one big exception: there are no frames. Or are there?

When you select an image in InCopy’s Layout view, you select the image, not its container. The question is then, how to get access to the container so it can place the image.

With a script, you have access to the container. It is the parent of the image. Using this knowledge plus the fact that the the image container and caption frame both have the same name, the script can be written. (Remember: the script that creates the placeholder image names both the image container and the text frame the same.)

The code following is the guts for the script PlaceImageWCap. It places the image, gets the image metadata, and populates the caption.


--calls to handlers to get references to the document and selected image
set docRef to getDocRef()
set imageRef to getSelection()
--have user choose the file
set imageToPlace to choose file with prompt "Select image for placing"
--call to handler that does the work
addContent (docRef, imageRef, imageToPlace)
--Here is where all the work is done
on addContent (docRef, imageRef, imageToPlace)
    tell application "Adobe InCopy CC"
        tell docRef            
            set rectRef to parent of imageRef
            --be sure rectangle is checked out
            check out rectRef
            set rectName to name of rectRef
            --place the image
            tell rectRef
                 place imageToPlace
                 fit given center content
            end tell
            --add caption
            set frameRef to text frame rectName --has same name as image container
            set storyRef to parent story of frameRef
            set placedImage to image 1 of rectRef
            set linkRef to item link of placedImage
            set linKM to properties of link xmp of linkRef
            set capStr to ""
            if author of linkM is not "" then
                set capStr to capStr + author of linkM & return
            end if
            if description of linkM is not "" then
                set capStr to capStr & description of linkM
            end if
            set contents of storyRef to capStr
            set applied paragraph style of paragraph 1 of storyRef to "Credit"
            set applied paragraph style of paragraph -1 of storyRef to "Caption"
        end tell
    end tell
end addContent


//calls to handlers to get references to the document, selected image, and chosen image file
    var docRef = getDocRef();
    var imageRef = getSelection();
    var imageToPlace = chooseFile_extTest ("Select Image file", "*.psd", [".PSD", ".JPG"], false);
     addContent (docRef, imageRef, imageToPlace);
    //call to handler that does the work
    function addContent (docRef, imageRef, imageToPlace){
        var creditStyle = docRef.paragraphStyles.itemByName("credit");
        var captionStyle = docRef.paragraphStyles.itemByName("caption");
        var rectRef = imageRef.parent;
        //make sure container is checked out
        var rectName =;;
        //add caption
        var frameRef = docRef.textFrames.itemByName(rectName);
        var placedImage = rectRef.images.item(0);
        var linkRef = placedImage.itemLink;
        var capStr = "";
        if ( != "") {
            capStr += + "\r";
        if (linkRef.linkXmp.description!= "") {
            capStr += linkRef.linkXmp.description
        var storyRef = frameRef.parentStory;
        storyRef.contents = capStr;
        storyRef.paragraphs.item(0).appliedParagraphStyle = creditStyleName;
        storyRef.paragraphs.lastItem().appliedParagraphStyle = captionStyleName;

Add error handling and subroutines (handlers and functions) to the code above and you can have a working script. Make sure you assign it to a keyboard shortcut and your InCopy users will love you. Watch for these scripts to be added to the InCopy Workflow collection. Modify the scripts for your own purpose and make the hassle of adding images and captions to your InCopy workflows a thing of the past.