Scrawls from Preston...

Powered by Pelican.

Tue 02 June 2009

Two quick collage assistants

Despite vowing to stay away from Applescript as far as I can - sometimes its the fastest way to save a little time

At work I'm involved in laying out our yearbook. Honestly a lot of these pages are just quick photo montages. I've made these in both Illustrator and Pages and each have some advantages - I use mostly Illustrator but its harder to have others help in that app.

I wanted to whip up some scripts that could take some of the scale and random rotation repetition out of the process, which these do - the pages version also adds drop shadow - both could be improved to do some repositioning...

The Pages version:

tell application "Pages"

set docName to name of document 1

tell document 1

--mark images:

set imagelist to get every image -- of body text

set an_image to item 1 of imagelist

repeat with an_image in imagelist

set w to width of an_image

set h to height of an_image

if w > h then

set width of an_image to 3


set height of an_image to 3

end if

set x to random number from -15 to 15

set rotation of an_image to x

set shadow of an_image to true

set shadow angle of an_image to 58.0

set shadow color of an_image to {0, 0, 0}

set shadow offset of an_image to 7

set shadow opacity of an_image to 75

set shadow blur of an_image to 7

--get properties of an_image

end repeat

end tell

end tell

The Illustrator version:

tell application "Adobe Illustrator"

set s to 2

set maxdim to 250

set page_items to page items of current document

repeat with an_item in page_items

set w to width of an_item

set h to height of an_item

if w > h then

set s to maxdim / w


set s to maxdim / h

end if

set width of an_item to w * s

set height of an_item to h * s

set x to random number from -15 to 15

set baseMatrix to get rotation matrix angle x

transform an_item using baseMatrix

end repeat

end tell