I have a script that runs in Quark which opens a linked image, resizes to 100%, saves and replaces said image. I recently upgraded my PhotoShop CS (to 5) and my Mac OS (to 10.6.4). Since those upgrades, the script doesn’t run. I don’t get an error message or anything, it just doesn’t start. The script indicates that it IS looking for PhotoShop CS5, but I don’t see a place that might specify why an operating system change would affect it.
Any ideas? (See below.)
tell application “QuarkXPress”
try
set xDoc to (properties of document 1)
on error – must not be a document open
ignoring application responses
display alert (“Please open a Quark Doc first!”) buttons {“Stop”} default button 1
return
end ignoring
end try
set xPath to my PathFix(file path of xDoc as string)
set xDocName to (name of xDoc as string)
tell document 1
set oldISC to item spread coords
set oldSRO to spread rule origin
set oldH to horizontal measure
set oldV to vertical measure
set item spread coords to true
set spread rule origin to {0, 0}
set horizontal measure to points
set vertical measure to points
set xUsage to (modified of every image)
if xUsage contains true then -- pictures are not updated
display alert ("Please update/fix all linked files first!") buttons {"Stop"} default button 1
return
end if
set xBoxes to (properties of every picture box where ((file type of image 1 = TIFF picture) or (file type of image 1 = JPEG picture))) as list
set xNum to 1
repeat with x in xBoxes
set myBox to (properties of object reference of x) --get picture box specs
set myHflip to (flipped horizontal of myBox)
set myVflip to (flipped vertical of myBox)
set myRot to (angle of image 1 of object reference of x)
set (angle of image 1 of object reference of x) to "0°"
set flipped horizontal of (object reference of x) to false
set flipped vertical of (object reference of x) to false
set myBox to (properties of object reference of x) --get picture box specs after flipped
set myImage to (properties of image 1 of object reference of myBox) -- get it's image specs
--get the scaling information
set xScale to (contents of scale of myImage)
tell image 1 of object reference of myBox
set xScale to (get scale as list)
end tell
--build the record info to send to Photoshop
set mySpecs to {iPath:"", iScale:{}} --get the specifics of the image: path, scaling
copy (file path of myImage as string) to iPath of mySpecs
copy (coerce item 2 of xScale to number) to end of iScale of mySpecs
copy (coerce item 1 of xScale to number) to end of iScale of mySpecs
set myNewPath to (my psSizing(mySpecs, xPath, xNum))
if myNewPath = "errorFound" then
display dialog ("Photoshop Error!!") buttons {"Bummer"} default button 1
return
end if
set file path of myImage to (contents of myNewPath) as alias
activate
tell (object reference of x)
set image 1 to (file path of myImage)
tell image 1
set scale to {"100%", "100%"}
set shade to (shade of myImage)
set skew to (skew of myImage)
set opacity to (opacity of myImage)
set offset to (offset of myImage)
set suppress printing to (suppress printing of myImage)
set angle to myRot
end tell
set flipped horizontal to myHflip
set flipped vertical to myVflip
end tell
do updates
set xNum to (xNum + 1)
end repeat
-- reset the measurements to the way they were
set item spread coords to oldISC
set spread rule origin to oldSRO
set horizontal measure to oldH
set vertical measure to oldV
end tell
ignoring application responses
display dialog ("Images have been re-sized to 100%") buttons {"Done"} default button 1
end ignoring
end tell
on volumeCheck() --mount the Layout volume
set xDrives to {}
tell application “Finder”
set xDrives to list disks
if not (xDrives contains “Layout”) then mount volume “afp://ICS-Xserve.local/Layout” as user name “macuser” with password “macuser”
end tell
end volumeCheck
on PathFix(docName)
set AppleScript’s text item delimiters to “:”
set xRemove to (the last text item of docName)
set AppleScript’s text item delimiters to “”
return (text from character 1 to character ((length of docName) - (length of xRemove)) of docName)
end PathFix
on getName(imagePath)
set AppleScript’s text item delimiters to “:”
set fName to (the last text item of imagePath)
set AppleScript’s text item delimiters to “”
return fName
end getName
on psSizing(thisImage, xPath, xNum)
tell application “Adobe Photoshop CS5”
activate
open file (contents of iPath of thisImage) showing dialogs never
if mode of current document = “RGB” then
return errorFound
end if
if mode of current document = bitmap then
set xRes to 601.0
else
set xRes to 300.0
end if
set xName to (my nameFix(name of current document, xNum)) – fix name of file
set xW to ((width of current document as inches) * xRes) as integer
set xH to ((height of current document as inches) * xRes) as integer
if (((item 1 of iScale of thisImage) < 1) or ((item 2 of iScale of thisImage) < 1)) then
set xMethod to bicubic smoother
else
set xMethod to bicubic sharper
end if
resize image current document ¬
width ((xW * (item 1 of iScale of thisImage)) as integer) as pixels ¬
height ((xH * (item 2 of iScale of thisImage)) as integer) as pixels ¬
resolution xRes resample method xMethod
set mySave to (contents of xPath as string) & (contents of xName as string)
save current document as TIFF in mySave
close current document
return (mySave)
end tell
end psSizing
on nameFix(xName, xNum) --fix the image name by adding the “loop count”
if xName ends with “.tif” then – remove extension & add loop count
set xName to (text from character 1 of xName to character ((length of xName) - 4) of xName)
end if
if xName ends with “.tiff” then – remove extension & add loop count
set xName to (text from character 1 of xName to character ((length of xName) - 5) of xName)
end if
if xName ends with “.jpg” then – remove extension & add loop count
set xName to (text from character 1 of xName to character ((length of xName) - 4) of xName)
end if
if xName ends with “.jpeg” then – remove extension & add loop count
set xName to (text from character 1 of xName to character ((length of xName) - 5) of xName)
end if
return (xName & “_” & xNum & “.tif”)
end nameFix
Model: iMac, 10.6.4
AppleScript: 2.1.2
Browser: Firefox 3.6.6
Operating System: Mac OS X (10.6)