How to produce an image Contact Sheet by way of AppleScript

I have found that the PDF contact sheet action in Automator doesn’t allow for labeling the images (with file name and/or creation date etc).
So, I thought I may try may hand at doing this by way of AppleScript.
Does anyone know whether AppleScript (or any application supplied with Mac OS X) is capable of doing this?
I can see how to get the images and scale them down, as well as find their names and/or creation dates, but I’m not really sure how to print them to a multi page pdf.
20 iMac G5/17 PowerBook/G4 400 AGP/iPod   Mac OS X (10.4.3)  

Hi,
What is your Quark Xpress version and MAC OS.
I am still working on it. Ihave almost completed but some bugs is there so it doesnot fulfill my requirements.
See the code below:
The problem line is in bold
=========
tell application "QuarkXPress™ 4.1_XU14777929963"
activate
set templateName to (choose file with prompt "Choose your template.")
open templateName use doc prefs yes
tell document 1
set horizontal measure to points
set vertical measure to points
end tell
set pageInfo to (properties of page 1 of spread 1 of document 1) as list
set topMargin to top margin of pageInfo as list
set pageLeftMargin to left margin of pageInfo as list
set bottomMargin to bottom margin of pageInfo as list
set rightMargin to right margin of pageInfo as list
tell page 1 of document 1
set pageBounds to bounds as list
set rightMargin to get right margin as real
set leftMargin to get left margin as real
set topMargin to get top margin as real
set bottomMargin to get bottom margin as real
set pageWidth to get page width of document 1 as real
set pageheight to get page height of document 1 as real
set tot to leftMargin + rightMargin
set totalPageWidth1 to pageWidth - rightMargin
set totalPageHeight1 to pageheight - topMargin
set maxWidth to totalPageWidth1 - tot
set maxHeight to totalPageHeight1 - tot
end tell
tell page 1 of document 1
make new picture box at beginning with properties {bounds:{0, 0, "1\"", "1\""}}
tell picture box 1
set colorbarImage to choose file with prompt "Find color bar."
set image 1 to colorbarImage
set colorbarBounds to bounds of image 1
set colorbarWidth to (item 3 of colorbarBounds) - (item 1 of colorbarBounds)
set colorbarHeight to (item 4 of colorbarBounds) - (item 2 of colorbarBounds)
end tell
delete picture box 1
end tell
set myFolder to choose folder with prompt "Choose your folder containing Images"
set layOnly to false
set myFolderText to myFolder as text
ignoring case
repeat with i from 4 to length of myFolderText
if character i of myFolderText = ":" then
if character (i - 1) of myFolderText = "s" then
if character (i - 2) of myFolderText = "e" then
if character (i - 3) of myFolderText = ":" then
set layOnly to true
display dialog ("Only .lay files will be processed")
end if
end if
end if
end if
end repeat
end ignoring
display dialog ("How many points to add to box size?") default answer "0" buttons {"OK"} default button 1
set addSize to text returned of result
set addSizePts to addSize as real
set theResults to (display dialog ("Enter Job Number") default answer "XXX" buttons {"No ID", "OK"} default button 2)
set textJob to text returned of theResults
set noID to button returned of theResults
if (noID = "No ID") then
set colorbarHeight to 0
set singlleImage to "Yes"
else
display dialog ("Enter batch identification") default answer "Art" buttons {"OK"} default button 1
set textBatch to text returned of result
display dialog ("Enter Chapter identification") default answer "Art" buttons {"OK"} default button 1
set textChapter to text returned of result
set textJobBatch to "Job:" & textJob & " Chapter:" & textChapter & " Batch:" & textBatch & "" as styled text
display dialog ("Enter date") default answer "EPG" buttons {"OK"} default button 1
set textDate to text returned of result
display dialog ("Enter Client Name") default answer "EPG" buttons {"OK"} default button 1
set textClientName to text returned of result
set textClientName to ("Client: " & textClientName)
display dialog ("Enter your code") default answer "IHK" buttons {"OK"} default button 1
set textOpName to text returned of result
set textDateOpNum to (return & "Date:" & textDate & "Operator:" & textOpName) as styled text
display dialog ("One image/page?") buttons {"YES", "NO"} default button 2
set singleImage to button returned of result
end if
copy (list folder (myFolder) without invisibles) to fileList
set currPage to 1
set currSpread to 1
set spreadInfo to (properties of spread currSpread of document 1) as list
set newPage to true
set imageOrigin to 0
-- set leftMargin to leftMargin
set columnWidth to 0
set totalImages to 0
if (noID = "No ID") then
set textBoxHeight to 0
set barCodes to true
else
set textBoxHeight to 58
set barCodes to true
end if
repeat with i from 1 to count of fileList
set imageFile to (myFolder as text) & (item i of fileList as text)
tell application "Finder"
try
set fileType to file type of imageFile
set creatorType to creator type of file imageFile
on error
set fileType to "RRRR"
end try
end tell
if fileType ≠ "fold" then --checking whether it is a folder or file
if ((fileType = "EPSF") or (fileType = "TIFF") or (fileType = "..CT") or (fileType = "JPEG") or (fileType = "GIFF")) then
ignoring case
if layOnly then
if (imageFile ends with ".lay") then
set processFile to true
else
set processFile to false
end if
else
if (imageFile ends with ".C") or (imageFile ends with ".M") or (imageFile ends with ".Y") or (imageFile ends with ".K") then
set processFile to false
else
set processFile to true
end if
end if
end ignoring
if processFile then
set totalImages to (totalImages + 1)
tell page currPage of spread currSpread of document 1
if (imageOrigin + colorbarHeight + textBoxHeight) > maxHeight then
make picture box at begining with properties {bounds:¬
{topMargin + colorbarHeight + imageOrigin, leftMargin, ¬
topMargin + colorbarHeight + imageOrigin + 36, leftMargin + 36}, color:"None"}
end if
tell picture box 1
set image 1 to alias imageFile
set imageBounds to bounds of image 1
set imageWidth to (item 3 of imageBounds) - (item 1 of imageBounds) + addSize
set imageHeight to (item 4 of imageBounds) - (item 2 of limageBounds) + addSize
set saveImageHeight to imageHeight
set saveImageWidth to imageWidth
if imageWidth < colorbarWidth then
set imageWidth to colorbarWidth
end if
end tell
if newPage = false then
ignoring case
if singleImage = "Yes" then
set leftMargin to (maxWidth + 1)
set imageOrigin to (maxHeight + 1)
end if
end ignoring
if (leftMargin + imageWidth) > maxWidth then
set leftMargin to (maxWidth + 1)
set imageOrigin to (maxHeight + 1)
end if
if (imagOrigin + colorbarHeight + imageHeight + textBoxHeight) > maxHeight then
delete picture box 1
set imageOrigin to 0
set newPage to true
set leftMargin to (leftMargin + columnWidth + 24)
set columnWidth to 0
if (leftMargin + imageWidth) > maxWidth then
set currPage to currPage + 1
if currPage > (item 6 of spreadInfo) then
set currSpread to currSpread + 1
set currPage to 1
tell document 1
make new spread at end
show spread currSpread
end tell
set leftMargin to pageLeftMargin
end if
end if
end if
else
set newPage to false
end if
end tell
set fullSize to true
tell page currPage of spread currSpread of document 1
if newPage = true then
set fullImageHeight to imageHeight
set fullImageWidth to imageWidth
if (imageHeight > (maxHeight - (colorbarHeight + textBoxHeight))) then
set imagHeight to (maxHeight - (colorbarHeight + textBoxHeight))
set fullSize to false
end if
if (imageWidth > maxWidth) then
set imagWidth to maxWidth
set fullSize to false
end if
make picture box at beginning with properties {bounds:¬
{topMargin + colorbarHeight + imageOrigin, leftMargin, ¬
topMargin + colorbarHeight + imageOrigin ¬
+ 36, leftMargin + 36}, color:"None"}
tell picture box 1
set image 1 to alias imagFile
set imageBounds to bounds of image 1
set colunWidth to imageWidth
end tell
set newPage to false
end if
tell picture box 1
set height of bounds to imageHeight
set width of bounds to imageWidth
set bounds of image 1 to «constant JUSTcent»
set boxBounds to bounds as list --box bounds reads as {A,B,C,D}
set BoxA to ((item 1 of boxBounds) as point units) as real --converts everything to points
set BoxB to ((item 2 of boxBounds) as point units) as real
set BoxC to ((item 3 of boxBounds) as point units) as real
set BoxD to ((item 4 of boxBounds) as point units) as real
if (noID ≠ "No ID") then
--set imageName to (name of image 1) as text
get file path of image 1 --gets the path name of the imported image
set pathName to result as text --converts the path name from a reference to text
set oldDelims to text item delimiters of AppleScript --puts the current delimiters into a placeholder
set text item delimiters of AppleScript to {":"} --uses the colon as the new delimiter
set fileName to last text item of pathName --asks for the last item of the delimited text string and sets it to variable
set text item delimiters of AppleScript to oldDelims --resets the old delimiters
(* if the operator enters "none" for the bar code, don't ask for any more bar codes *)
if barCodes then
display dialog ("Enter bar code for image " & fileName) ¬
default answer "none" buttons {"OK"} default button "OK"
set textBarCode to text returned of result
if (textBarCode = "none") or (textBarCode = "NONE") or (textBarCode = "None") then
set textBarCode to ""
set barCodes to false
(* set textBoxHeight to 36 *)
else
if textBarCode ≠ "" then
(* set textBarCode to (return & "Bar Code: " & textBarCode) as styled text *)
set textBarCode to (" Bar Code: " & textBarCode)
end if
end if
else
set textBarCode to ""
end if
if (creatorType = "ART5") then
set textCreator to " Creator: Illustrator"
else if (creatorType = "8BIM") then
set textCreator to " Creator: PhotoShop"
else if (creatorType = "FH40") then
set textCreator to " Creator: FreeHand"
else
set textCreator to " CreatorID: " & creatorType as text
end if
--set textClientBarCode to (return & textClientName & textBarCode) as styled text
set textClientBarCode to (return & textClientName & textBarCode & textCreator) as styled text
if fullSize then
set sizeDisclaimer to ""
else
set sizeDisclaimer to " (complete image is not displayed; full size=" & (saveImageWidth as text) ¬
& " x " & (saveImageHeight as text) & ")"
end if
end if
end tell
if (noID ≠ "No ID") then
set textIDSize to (return & "Fig: " & fileName & " Size: " & (saveImageWidth as text) ¬
& " X" & (saveImageHeight as text)) as styled text
(* add a box identifying the figure including job, batch, client, barcode, name, size, date and oper *)
make new text box at beginning with properties ¬
{bounds:{BoxC + 6, BoxB, BoxC + 6 + textBoxHeight, BoxD}, runaround:none runaround, color:"None"} ¬
if sizeDisclaimer ≠ "" then
set story 1 of text box 1 to (fileName & sizeDisclaimer) as styled text
else
set story 1 of text box 1 to (textJobBatch & textClientBarCode & textIDSize & textDateOpNum) as styled text
end if
set justification of story 1 of text box 1 to «constant JUSTcent»
if sizeDisclaimer = "" then
tell paragraph 1 of story 1 of text box 1
(* if (word count) = 2 then *)
(* set style of word 1 to bold *)
(* set style of word 2 to italic *)
(* else *)
set style of word 1 to «constant Stylbold»
(* word 3 *)
--select character 1
(*set textArray to words as list
set arrayLength to length of textArray
repeat with i from 1 to arrayLength
set paraLength to count of words
repeat with i from 1 to paraLength
if word i = "Batch" then
set style of word i to «constant Stylbold»
else if word i = "Chapter" then
set style of word i to «constant Stylbold»
end if
end repeat
(* end if *)
end tell
(* if textBarCode ≠ "" then *)
tell paragraph 2 of story 1 of text box 1
set style of word 1 to «constant Stylbold»
set paraLength to count of words
if textBarCode ≠ "" then
(* set style of words 1 through 2 to bold *)
(* word count *)
repeat with i from 1 to paraLength
if word i = "Bar" then
set style of words i thru (i + 1) to ¬
«constant Stylbold»
end if
end repeat
end if
repeat with i from 1 to paraLength
if word i = "Creator" then
set style of word i to «constant Stylbold»
else if word i = "CreatorID" then
set style of word i to «constant Stylbold»
end if
end repeat
end tell
(* end if *)
tell paragraph 3 of story 1 of text box 1
set style of word 1 to «constant Stylbold»
(* word count *)
set paraLength to count of words
repeat with i from 1 to paraLength
if word i = "Size" then
set style of word i to «constant Stylbold»
end if
end repeat
end tell
tell paragraph 4 of story 1 of text box 1
set style of word 1 to «constant Stylbold»
set paraLength to count of words
repeat with i from 1 to paraLength
if word i = "Oper" then
set style of word i to «constant Stylbold»
end if
end repeat
(* word count *)
end tell
tell text box 1
show
set heightAdjustment to 6
set item3 to (BoxC + 6 + textBoxHeight + heightAdjustment)
--repeat while box overflows and (item3 < maxHeight)
repeat while box overflows
--if box overflows then
set bounds to {BoxC + 6, BoxB, item3, BoxD}
set heightAdjustment to heightAdjustment + 6
set item3 to (BoxC + 6 + textBoxHeight + heightAdjustment)
--end if
end repeat
end tell
end if
end if
if (noID ≠ "No ID") then
(* add the color bar *)
make picture box at beginning with properties ¬
{bounds:{BoxA - colorbarHeight - 1, BoxB, BoxA - 1, BoxB + colorbarWidth}, color:"None"}
tell picture box 1
set image 1 to colorbarImage
end tell
set imageOrigin to BoxC + textBoxHeight -- starting point of next image
if imageWidth > columnWidth then
set columnWidth to imageWidth
end if
end if
end tell
end if
end if
end if
end repeat
display dialog (totalImages as text) & " images processed in " & myFolder & ". " buttons {"OK"} default button {"OK"}
tell document 1
show page -1 --last page
end tell
end tell
Thanks
Rajeev

Similar Messages

  • How can I save my contact sheets in Photoshop Lightroom?

    How can I save my contact sheets in Photoshop Lightroom? I see that you create the sheets under the Print tab but how can I save them as jpgs to my desktop?

    Kittie,
    I use this workflow and it works really well for me; it's really strange that it
    i did
    work for you and now it doesn't.
    I had a quick dabble and
    i may
    have an explanation. If I read your error message it looks like "New Folder" is trying to create a folder ~kittie/Desktop/3 Working/Contact Pages. However, the automator "create folder" won't create folders recursively like that - it will only work if "3 Working" already exists. Certainly I was able to reproduce the 'quick flash error message and bomb out with no results' effect by asking it to produce a directory from one that didn't already exist. When I added two Finder actions it didn't work as I expected - producing 74 files in subdirectories that just looped round and round when I expected one file and one directory.
    I added a shell script that renames the files too and it all works just dandy for me. If you let me know your e-mail I'll post the automator "app" file and shell script I use. It gives you sensibly named files instead of the sdkjfdfadkljfb.jpeg thing that comes out of automator.
    Damian

  • How to create a Proof/Contact sheet in CS5??

    Hey there,
    I'm using Bridge CS5 and trying to work out how to create a Proof/Contact sheet as then save as a PDF?
    I found a tutorial online, but when I followed the instructions and went into the 'Output' Workspace... the actual Output Panel doesn't come up, and I'm confused why.
    Please help

    Hi there
    The help is saying to click View > Toolbars > Formatting (in case the toolbar has been turned off)
    Perhaps the image below will better assist in locating the icon.
    Cheers... Rick

  • How can you create a contact sheet that you can email?

    I see that you can print a contact sheet but how can you make a contact sheet that you can email where receiver can open the thumbnails and view?

    Hi,
    You can either use Bridge and the Output workspace, or grab optional plug-ins for CS5 and run Ps on OSX in the 32 bit mode. (Or grab the excellent 3rd party script, Contact Sheet X, and run that in Ps. http://ps-scripts.sourceforge.net/ContactSheetX/csx.html).
    Here's a post with links to further info:
    http://blogs.adobe.com/jkost/2011/09/the-contact-sheet-feature.html
    regards,
    steve

  • How do i print a contact sheet of pictures?

    how do i print a contact sheet of pictures?

    Open the conatct sheet and command-P to select your printer and there you go.

  • How do I save my contact sheets as a file instead of printing?

    How do I save my contact sheets as a file instead of printing?

    In Aperture 3 there are two print dialogs. The first is Aperture specific. After you finish this dialog the printer specific dialog will open. In the PDF menu choose Save as PDF...
    I've forgotten how Aperture 2 works but it has a different print dialog I think. Look for the same PDF menu or a Preview button.

  • How do you print a contact sheet in sequential order please?

    How do you print a contact sheet in sequential or file order number please

    If you have the Mac version of iWork/Numbers you can print individual sheets.  My sheets are "printed" on separate pages when using the iCloud beta, so another option may be to print just a range of pages (or a single page) via the print dialog setting in Preview (or your PDF viewer app).

  • How do I create a Contact sheet in CS6

    How do I create a Contact sheet in CS6 using Mac OSX 10.9.2? I have used the 'video help' but my drop down menu doesn't correspond to the advice given.

    CS6 is a version number... what actual program are you using?
    If you start at the Forums Index http://forums.adobe.com/index.jspa
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says ALL FORUMS) to open the drop down list and scroll

  • How to create and print contact sheet using photoshop elements 10?

    how to create and print contact sheet with photoshop 10?

    Which operating system are you using?
    On a windows system you can use the Organizer
    http://www.dummies.com/how-to/content/how-to-print-contact-sheets-in-photoshop-elements-.h tml
    On a Mac, File>Contact Sheet II within the pse 10 editor

  • Print Images' Contact Sheet problems from specific camera...

    I have printed a couple contact sheets (Print Images > Contact Sheet), and all the thumbnails for RAW files from a Panasonic DMC-LX2 all come out squooshed into a square, no matter what the actual orientation of the file is. I have forced an update of the previews and there is no change. Is this a common problem for others? In the preview for printing single images to a page, the images appear normal, but with contact sheets the images from this camera come out square. No problems with my Canon files or other JPGs.
    I suspect there is no work-around, but ask just in case. It would be nice if there is, as the contact sheets are for a copyright registration, and the square makes the image possibly illegible in the eyes of a future court, if it ever got to that.

    HAs this already been discussed and fixed? hopefully?
    It appears to be a bug.
    http://discussions.apple.com/message.jspa?messageID=3553568&tstart=0

  • How can I print a contact sheet with a repeated row of images?

    Hi there,
    I am hoping that it is possible with my version of iPhoto to print a contact sheet on which I need to have a row of 8 pictures that then repeat down the entire page.
    I understand how to set the slider for the number of "rows" across the page. But, how do I then get these 8 pictures to repeat on the same piece of paper?
    I am an art teacher...need to do this for a project for my class!
    thanks for any help that may lead me to success...
    peace,
    Robin

    A contact sheet can only put each photo once on the page. I can't think of a way to do it in iPhoto.
    I was able to do what you describe in Photoshop Elements. If you have access to that program you can give it a try.
    In Photoshop Elements, open all 8 photos.
    Choose File->Contact Sheet II
    Source Images Use: Current Open Documents
    Thumbnails: Place across first, Columns: 8, Rows 1 (Use Auto Spacing)
    Uncheck "Use Filename as Caption" unless you want the names.
    Click OK.
    You then need to move the row of photos to the top of the page with the move tool. Then while holding down the option and shift keys, use the move tool to drag copies repeatedly until you've filled the page.

  • Automator: How to create a PDF contact sheet?

    Hi,
    I'm trying to create a PDF from multiple images in automator. The PDF should contain:
    First Page: A contact sheet with all images
    Following pages: One page for each image
    Any idea how to achieve this? I don't even get the contact sheet working – it always results in a blank PDF.
    Kind regards
    Jan

    Thanks for your reply. Unfortunately the intructions in the link don't work (did it exactly like this -> result is an empty PDF). I learned now from other posts that this is a Mavericks specific issue, which seems to be unsolved.
    Apart from this: Do you think my request is solvable at all? Because the output of the contact sheet module would be the contact sheet iteslf (if it worked). I can't use this to create the full sized PDF pages, right?

  • How to include ratings in contact sheets in Bridge CS4??

    I'm trying to find out how to include my ratings and labels in a contact sheet, to share that with someone who is not going to use Bridge but ideally just a PDF. Is that at all possible? Thanks!

    Is that at all possible?
    To my knowledge not in the AOM settings, the options inhere are still a bit limited. But you can use the sort order for rating and in combination with batch rename you could be a bit creative by adding a mark like 1 star or 2 stars to the filename for the selected files. Or use same rated files per page.

  • HT1229 how do I make a contact sheet?

    i want to make and organize a contact sheet with about 9 to 12 photos.  How do i do this?

    What version of iPhoto do you have?  With iPhoto 9.6 select the photos you want on the contact sheet and type Command-P to start a print process.   In the Print window click on the Contact Sheet layout.  Then you can select the number of columns and, under settings, select what information to print under each photo:

  • How do I save a contact sheet?

    How do I make and save a contact sheet as I don't print at home so need to save it not print it? I have Elements 5, just ordered Elements 7 (havent even recieved it yet) and now 8 has been released (don't you hate that!). Help will be appreciated!

    PDF995 is a free utility that converts any kind of document into a PDF file.  It functions like a printer driver.  Instead of sending the document (the contact sheet) to a real printer, send it to PDF995, which will create a PDF file that can be printed anywhere.
    http://www.pdf995.com/download.html
    Another free utility is IrfanView (www.irfanview.com).  It will let you create and save contact sheets in JPEG or other picture formats.
    Juergen

Maybe you are looking for