This script is suppose to check if a link is at 100% in ID and if not, resize it to the proper size in PS and relink it in ID. It does a descent job, but for an unknown reason, doesn’t do all links.
I’ve tried to isolate the problem but since I didn’t write the script innitially I have no idea where to look.
I’ve tried to check after the line
set ImagePath to file path of item myCounter of IDLinks as string
with a get IDlinks and every image is listed, so I guess the problem lies further except that I don’t know how to disect the script in portion to isolate the problem.
Anyway, here is the script, it’s pretty long, sorry and thanks for any help.
--ResampleImages.as
--Resamples all images in the active document (using Photoshop)
--to their scaled size; sets the scaling on all frames to 100%.
set myProcessedLinks to {}
set myFolder to choose folder with prompt "Select a destination folder for resampled images"
tell application "InDesign CS"
set myDocument to active document
tell myDocument
set outdateLinks to every link whose status is link out of date
repeat with OODLinks from (count outdateLinks) to 1 by -1
update link of item OODLinks of outdateLinks
end repeat
set IDLinks to every link whose status is normal
--Iterate backwards through the links to avoid invalidating objects.
repeat with myCounter from (count IDLinks) to 1 by -1
set myLink to item myCounter of IDLinks
--Process only image links.
set myLinkType to link type of myLink
--If statement could be expanded to include other image types.
if myLinkType = "TIFF" or myLinkType = "EPS" or myLinkType = "Photoshop format" or myLinkType = "PDF" then
set LinkName to name of myLink
set theImage to parent of myLink
set theFrame to parent of theImage
--get the path
set ImagePath to file path of item myCounter of IDLinks as string
--get the image's location
set ImgPos to geometric bounds of theImage
set FramePos to geometric bounds of theFrame
--get the scale
set myHoriz to horizontal scale of theImage as real
set myVert to vertical scale of theImage as real
--get the bounds of the image
set myY1 to (item 1 of ImgPos)
set myX1 to (item 2 of ImgPos)
set myY2 to (item 3 of ImgPos)
set myX2 to (item 4 of ImgPos)
--If the image has been scaled to something other than 100%,
--and if it has not already been resized in photoshop...
if myHoriz is not 100 and myHoriz = myVert and ImagePath is not in myProcessedLinks then
set myFileName to my myMakeFileName(myFolder, ImagePath as alias, myHoriz)
--...then scale the graphic in Photoshop:
tell application "Adobe Photoshop CS"
--activate
open file ImagePath
set docRef to current document
resize image docRef width percent (myHoriz / 100) resample method bicubic sharper
--If...else if statement could be expanded to handle other file types.
if myLinkType = "TIFF" then
set myImageDocument to save docRef in file myFileName as TIFF
else if myLinkType = "EPS" then
set myImageDocument to save docRef in file myFileName as EPS
else if myLinkType = "Photoshop format" then
set myImageDocument to save docRef in file myFileName as Photoshop format
else if myLinkType = "PDF" then
set myImageDocument to save docRef in file myFileName as PDF
end if
set myFileName to file path of myImageDocument
close current document saving no
--close docRef with saving
end tell
relink myLink to myFileName
--When you update the link, the old link is destroyed
--and InDesign returns the new link.
set myLink to update myLink
set theImage to parent of myLink
set theFrame to parent of theImage
set properties of theFrame to {horizontal scale:100, vertical scale:100, geometric bounds:FramePos}
set properties of theImage to {horizontal scale:100, vertical scale:100, geometric bounds:ImgPos}
copy myFileName to end of myProcessedLinks
else if ImagePath is in myProcessedLinks then
set myLink to update myLink
end if
end if
end repeat
end tell
end tell
on myMakeFileName(myFolder, myFile, myHoriz)
set myFileInfo to info for myFile
set myFileName to name of myFileInfo
set myFolderName to myFolder as string
if (myHoriz as string) contains "." then
set myOldDelimiters to text item delimiters
set text item delimiters to "."
set myHoriz to text item 1 of (myHoriz as string)
set text item delimiters to myOldDelimiters
end if
if myFileName contains "." then
set myOldDelimiters to text item delimiters
set text item delimiters to "."
set myFileName to text item 1 of myFileName
set text item delimiters to myOldDelimiters
end if
set myNewFileName to myFileName & "_" & (myHoriz as string)
set myNewFilePath to myFolderName & myNewFileName
return myNewFilePath
end myMakeFileName