Drawing on the Photoshop side of the brain

Blognosticator Head

A few blogs ago I wrote about how to use AppleScript to crop a Photoshop document with pixel precision. As part of that same project, I needed to add white space to the canvas and trim marks top and bottom along the edges to mark the location of a cut that was made later on a large metal cutting shear.

The resizing of the canvas is easy. The AppleScript code looks like this:

resize canvas _CroppedPano width 11287 height 17700

This, of course, must be placed within the construct of a script, but looking at the syntax of the instruction, it says simply, “make the canvas bigger (or smaller) to these dimensions: 11287 X 17700 pixels.” AppleScript and Photoshop will carry out your instructions without delay and without asking if it’s OK, so be careful to be accurate with any script that makes changes like this.

_CroppedPano is my variable name for the photo on which I am making the changes.

Now let’s look at how the crop marks are drawn. Photoshop, like Illustrator, uses the Cartesian coordinate system for all of its measurements. Upper-left is 0,0 (early versions of Illustrator put that 0,0 at the lower-left). Photoshop measures everything in the current measurement unit, whatever that may be. At the top of my script I tell Photoshop to use the pixel unit of measure:

set ruler units of settings to pixel units

From this moment on, the program is computing values in pixels.

This is the way Cartesian coordinates work in Photoshop (and everywhere else):

Print

The crop marks I want to draw are one pixel wide and 150 pixels tall (in this example, that’s 1/2 inch). I needed one at the top and bottom of each panel, on both the left and right edges, and one-half inch in from the edges (these are crop marks).

Here is the code for the AppleScript to make the first mark at the upper-left of the photo:

set _LineShape to {{150, 0}, {150, 150}, {151, 150}, {151, 0}}
select current document region _LineShape
fill selection of current document with contents {class:RGB color, red:0, green:0, blue:0} opacity 100 without preserving transparency
deselect current document

Parsing those lines of code, the first line lists the Cartesian coordinates of a 1-pixel by 150-pixel rectangle, located 150 pixels from the left edge of the image. The second line of code tells Photoshop to create the variable _LineShape (which is the name of the line I am drawing). The next line fills the shape with black (RGB 000) with 100% opacity and no transparency. The last line deselects the current selection so that I can make another selection.

The other three crop marks are made the same way, but with different coordinates in the x,y positions for all corners.

At the end of the script I return Photoshop to inches units for measure:

set ruler units of settings to inch units

…and then I end the script. The result is a photo with a larger canvas (the background color is used to expand the canvas) and crop marks on the corners:

Running the script – even on multi-gigabyte files – takes just a few seconds. It is absolutely precise and absolutely repeatable.

Here is a photo showing crop marks like those I have described here:

Burning Man at with marks

Notice that it has pairs of one-pixel-wide crop marks top and bottom, left and right. That is exactly what the script does, after it increases the canvas size.

When you need precision, and I often do, using techniques like this can make a job successful where dragging rectangles on screen will not be as accurate.

 

About Brian Lawler

Brian Lawler is an Emeritus Professor of Graphic Communication at California Polytechnic State University, San Luis Obispo. He writes about graphic arts processes and technologies for various industry publications, and on his blog, The Blognosticator.
This entry was posted in Photography, Technology and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.