Yeah, I did. I don’t remember if you had the script for the CS2 suite, since I’ve updated that version only, here it is.
--ResampleImages24.as
--Resamples all images in the active document (using Photoshop)
--to their scaled size; sets the scaling on all frames to 100%.
--version updated to work on tiff, psd and eps from Photoshop
myDisplayDialog()
on myDisplayDialog()
tell application "Adobe InDesign CS2"
activate
set myDialog to make dialog with properties {name:"Resample images"}
tell myDialog
tell (make dialog column)
--Dialog row containing integer editbox.
tell (make dialog row)
tell (make dialog column)
make static text with properties {static label:"dpi:"}
end tell
tell (make dialog column)
set myIntegerEditbox to make integer editbox with properties {edit value:300}
end tell
end tell
end tell
end tell
set myResult to show myDialog
if myResult is true then
--Get the values from the various editboxes.
set myInteger to edit value of myIntegerEditbox
destroy myDialog
set myProcessedLinks to {}
set myFolder to choose folder with prompt "Select a destination folder for resampled images"
tell application "Adobe InDesign CS2"
--If transformation preferences are not set to transformations are totals
--we have to set them for the script to work.
if transformations are totals of transform preferences is false then
set myOldTransPreferences to properties of transform preferences
set transformations are totals of transform preferences to true
set show content offset of transform preferences to true
set dimensions include stroke weight of transform preferences to true
set transform content of transform preferences to true
set myResetTransform to true
else
set myResetTransform to false
end if
set mydocument to active document
tell mydocument
--If the measurement units of the active document are not inches, set the
--measurement units to inches. Units MUST be inches in order to script work.
if horizontal measurement units of view preferences of mydocument is not points or ¬
vertical measurement units of view preferences of mydocument is not points then
set myOldViewPreferences to properties of view preferences of mydocument
set horizontal measurement units of view preferences of mydocument to points
set vertical measurement units of view preferences of mydocument to points
set myResetUnits to true
else
set myResetUnits to false
end if
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 myLinkedFile to file path of myLink as alias
set myLinkType to link type of myLink
tell application "Finder" to set fileCreator to file creator of (info for myLinkedFile)
--If statement expanded to isolate PS EPS from AI EPS.
if (myLinkType = "TIFF") or (myLinkType = "Photoshop") or ((myLinkType = "EPS") and (fileCreator = "8BIM")) then
set LinkName to name of myLink
set theImage to parent of myLink
set theFrame to parent of theImage
-- resets the graphic frame to 100
reset scaling of theFrame
--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 absolute horizontal scale of theImage
if myHoriz is less than 0 then
set myImageFlipHoriz to -100
else
set myImageFlipHoriz to 100
end if
set myVert to absolute vertical scale of theImage
if myVert is less than 0 then
set myImageFlipVert to -100
else
set myImageFlipVert to 100
end if
-- Check if frame as been flipped
if the absolute horizontal scale of theFrame is -100 then
set myHorizFrameHeight to 100
set myFrameFlipHoriz to -100
else
set myHorizFrameHeight to (absolute horizontal scale of theFrame)
set myFrameFlipHoriz to 100
end if
if the absolute vertical scale of theFrame is -100 then
set myVertFrameWidth to 100
set myframeFlipVert to -100
else
set myVertFrameWidth to (absolute vertical scale of theFrame)
set myframeFlipVert to 100
end if
if (myImageFlipHoriz + myFrameFlipHoriz) is 0 then
set myFinalHorizFlip to -100
else
set myFinalHorizFlip to 100
end if
if (myImageFlipVert + myframeFlipVert) is 0 then
set myFinalHorizVert to -100
else
set myFinalHorizVert to 100
end if
--get the rotation and Shear of the frame
set FrameRot to rotation angle of theFrame
set FrameShear to shear angle of theFrame
--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 myHorizFrameHeight is 100 and myHorizFrameHeight = myVertFrameWidth and ImagePath is not in myProcessedLinks and myHoriz is not 100 then
set myFileName to my myMakeFileName(myFolder, ImagePath as alias, myHoriz)
--...then scale the graphic in Photoshop:
tell application "Adobe Photoshop CS2"
--activate
set ruler units of settings to point units
open file ImagePath showing dialogs never
set docRef to current document
--resizing images that are proportionally scaled
--resize image docRef width percent (myHoriz / 100) resample method none
--resize image docRef resolution 300 resample method bicubic sharper
--resizing images proportionaly and non proportionaly scaled
resize image docRef width percent (myHoriz) height percent (myVert) resolution (myInteger) 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 = "Photoshop" then
set myImageDocument to save docRef in file myFileName as Photoshop format
else if myLinkType = "EPS" then
set myImageDocument to save docRef in file myFileName as Photoshop EPS with options {class:EPS save options, encoding:binary, preview type:JPEG Mac OS}
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, rotation angle:FrameRot, shear angle:FrameShear}
set properties of theImage to {horizontal scale:myFinalHorizFlip, vertical scale:myFinalHorizVert, geometric bounds:ImgPos}
resize theImage horizontal scale 100 vertical scale 100 around center anchor without considering current scale and considering parents scale
copy myFileName to end of myProcessedLinks
else if ImagePath is in myProcessedLinks then
set myLink to update myLink
end if
end if
end repeat
--Resets the units
if myResetUnits is true then
tell view preferences of mydocument to set properties to myOldViewPreferences
end if
end tell
if myResetTransform is true then
tell transform preferences to set properties to myOldTransPreferences
end if
end tell
else
destroy myDialog
end if
end tell
end myDisplayDialog
on myMakeFileName(myFolder, myFile, myHoriz)
set myFileInfo to info for myFile
set myFileName to name of myFileInfo
set myFolderName to myFolder as string
set myHoriz to (round myHoriz) as string
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
tell application "Adobe InDesign CS2"
activate
beep
display dialog "Done!"
end tell
You’d have to compare both script and reinstate the part that are CS specific. I think just changing the name of the CS2 app to the ones of CS will do most of it. I remember that there is a part in the photoshop format that you need to set to “Photoshop format” instead of “photoshop” and that’s about it.
Thanks… I got it to work…
Any further clue about the “not processing” of all images… when InDesign thinks it’s a picture inside a box INSIDE another box??? Just wondering… not that big a deal. Thanks again for your help.
Revision:
I had to edit your script to also change the resizing. When I ran yours it resized at the absolute value not the percentage… so I added the “/100” to make it scale correctly.
oh, yeah, I had forgoten about that one. If you let it with the /100 in CS2 it’s like it scales the item two times. My latest version works for ID CS2 and PS CS2.
I have just upgraded to CS3 and can’t get this script to work. I have updated the script to run InDesign CS3 and Photoshop CS3.
The error I am getting is “Syntax Error: Expected end of line, etc. but found identifier”, which occurs here (line 78):
" – resets the graphic frame to 100
reset scaling of theFrame"
The same error as above occurs in the following line as well (line 179):
" resize theImage horizontal scale 100 vertical scale 100 around center anchor without considering current scale and considering parents scale"
I don’t know if there are any other compatibility issues with this script and CS3 as I haven’t been able to run it. If anyone has had any luck updating this script, please post your solution.
Hi,
in InDesignCS3 there is a new transform preference:
set when scaling of transform preferences to apply to content
So init InDesign like this:
tell application "Adobe InDesign CS3"
if transformations are totals of transform preferences is false then
set oldTransPrefs to properties of transform preferences
set transformations are totals of transform preferences to true
set show content offset of transform preferences to true
set dimensions include stroke weight of transform preferences to true
set when scaling of transform preferences to apply to content
set resetTrans to true
else
set resetTrans to false
end if
-- do something
if resetTrans then
tell transform preferences to set properties to oldTransPrefs
end if
end tell
And in CS3 the “reset” and “resize” commands doesnt work… (not available anymore and you dont need them in CS3)
Hi,
here is the updated script (implement the new transform preference and comment out the old script-commands “resize” and “reset” for IDCS3).
I have no time to test this script, so use it on own risk:
--ResampleImages24.as
--Resamples all images in the active document (using Photoshop)
--to their scaled size; sets the scaling on all frames to 100%.
--version updated to work on tiff, psd and eps from Photoshop
myDisplayDialog()
on myDisplayDialog()
tell application "Adobe InDesign CS3"
activate
set myDialog to make dialog with properties {name:"Resample images"}
tell myDialog
tell (make dialog column)
--Dialog row containing integer editbox.
tell (make dialog row)
tell (make dialog column)
make static text with properties {static label:"dpi:"}
end tell
tell (make dialog column)
set myIntegerEditbox to make integer editbox with properties {edit value:300}
end tell
end tell
end tell
end tell
set myResult to show myDialog
if myResult is true then
--Get the values from the various editboxes.
set myInteger to edit value of myIntegerEditbox
destroy myDialog
set myProcessedLinks to {}
set myFolder to choose folder with prompt "Select a destination folder for resampled images"
tell application "Adobe InDesign CS3"
--If transformation preferences are not set to transformations are totals
--we have to set them for the script to work.
if transformations are totals of transform preferences is false then
set myOldTransPreferences to properties of transform preferences
set transformations are totals of transform preferences to true
set show content offset of transform preferences to true
set dimensions include stroke weight of transform preferences to true
(*
set transform content of transform preferences to true
*)
set when scaling of transform preferences to apply to content
set myResetTransform to true
else
set myResetTransform to false
end if
set mydocument to active document
tell mydocument
--If the measurement units of the active document are not inches, set the
--measurement units to inches. Units MUST be inches in order to script work.
if horizontal measurement units of view preferences of mydocument is not points or ¬
vertical measurement units of view preferences of mydocument is not points then
set myOldViewPreferences to properties of view preferences of mydocument
set horizontal measurement units of view preferences of mydocument to points
set vertical measurement units of view preferences of mydocument to points
set myResetUnits to true
else
set myResetUnits to false
end if
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 myLinkedFile to file path of myLink as alias
set myLinkType to link type of myLink
tell application "Finder" to set fileCreator to file creator of (info for myLinkedFile)
--If statement expanded to isolate PS EPS from AI EPS.
if (myLinkType = "TIFF") or (myLinkType = "Photoshop") or ((myLinkType = "EPS") and (fileCreator = "8BIM")) then
set LinkName to name of myLink
set theImage to parent of myLink
set theFrame to parent of theImage
-- resets the graphic frame to 100
(*
reset scaling of theFrame
*)
--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 absolute horizontal scale of theImage
if myHoriz is less than 0 then
set myImageFlipHoriz to -100
else
set myImageFlipHoriz to 100
end if
set myVert to absolute vertical scale of theImage
if myVert is less than 0 then
set myImageFlipVert to -100
else
set myImageFlipVert to 100
end if
-- Check if frame as been flipped
if the absolute horizontal scale of theFrame is -100 then
set myHorizFrameHeight to 100
set myFrameFlipHoriz to -100
else
set myHorizFrameHeight to (absolute horizontal scale of theFrame)
set myFrameFlipHoriz to 100
end if
if the absolute vertical scale of theFrame is -100 then
set myVertFrameWidth to 100
set myframeFlipVert to -100
else
set myVertFrameWidth to (absolute vertical scale of theFrame)
set myframeFlipVert to 100
end if
if (myImageFlipHoriz + myFrameFlipHoriz) is 0 then
set myFinalHorizFlip to -100
else
set myFinalHorizFlip to 100
end if
if (myImageFlipVert + myframeFlipVert) is 0 then
set myFinalHorizVert to -100
else
set myFinalHorizVert to 100
end if
--get the rotation and Shear of the frame
set FrameRot to rotation angle of theFrame
set FrameShear to shear angle of theFrame
--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 myHorizFrameHeight is 100 and myHorizFrameHeight = myVertFrameWidth and ImagePath is not in myProcessedLinks and myHoriz is not 100 then
set myFileName to my myMakeFileName(myFolder, ImagePath as alias, myHoriz)
--...then scale the graphic in Photoshop:
tell application "Adobe Photoshop CS3"
--activate
set ruler units of settings to point units
open file ImagePath showing dialogs never
set docRef to current document
--resizing images that are proportionally scaled
--resize image docRef width percent (myHoriz / 100) resample method none
--resize image docRef resolution 300 resample method bicubic sharper
--resizing images proportionaly and non proportionaly scaled
resize image docRef width percent (myHoriz) height percent (myVert) resolution (myInteger) 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 = "Photoshop" then
set myImageDocument to save docRef in file myFileName as Photoshop format
else if myLinkType = "EPS" then
set myImageDocument to save docRef in file myFileName as Photoshop EPS with options {class:EPS save options, encoding:binary, preview type:JPEG Mac OS}
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, rotation angle:FrameRot, shear angle:FrameShear}
set properties of theImage to {horizontal scale:myFinalHorizFlip, vertical scale:myFinalHorizVert, geometric bounds:ImgPos}
(*
resize theImage horizontal scale 100 vertical scale 100 around center anchor without considering current scale and considering parents scale
*)
copy myFileName to end of myProcessedLinks
else if ImagePath is in myProcessedLinks then
set myLink to update myLink
end if
end if
end repeat
--Resets the units
if myResetUnits is true then
tell view preferences of mydocument to set properties to myOldViewPreferences
end if
end tell
if myResetTransform is true then
tell transform preferences to set properties to myOldTransPreferences
end if
end tell
else
destroy myDialog
end if
end tell
end myDisplayDialog
on myMakeFileName(myFolder, myFile, myHoriz)
set myFileInfo to info for myFile
set myFileName to name of myFileInfo
set myFolderName to myFolder as string
set myHoriz to (round myHoriz) as string
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
tell application "Adobe InDesign CS3"
activate
beep
display dialog "Done!"
end tell