I’m creating a script to check if I have any lo-res images in my document, using effective ppi (Yes I know about preflight) and just pop up a message. However I’m stuck on checking the results the following is returning.
tell application "Adobe InDesign CS6"
activate
tell document 1
set minimumRes to 100
set theEffectiveRes to {}
set theLink to every link
repeat with x from 1 to count of theLink
set the end of theEffectiveRes to effective ppi of parent of link x
end repeat
-- Here I need to check theEffectiveRes for any entires below minimumRes and display a message
end tell
end tell
log theEffectiveRes
You can determine the effective resolution with the following:
dpi of image/scale percentage x 100
so for an image of 300 dpi scaled at 240% the effective res is 300/240x100 = 125dpi
So within your repeat routine, you would have to determine each images actual resolution, determine the % at which it is placed in InDesign, then do the maths. (Then compare to your minimumRes)
Thanks for the reply, but I’m already getting the effective ppi from the query, I just need a way to query the returned vales, I’m getting all the ppi’s returned as 12.032.072.0 rather than separate numbers?
The effective pip should be returned as a list of two values, the horizontal and vertical resolution. If you know they are all going to be the same horizontally as vertically, just use:
set the end of theEffectiveRes to item 1 of (effective ppi of parent of link x)
Hi, Shane(s). It’s fairly common for there to be images stretched disproportionally to fill a frame, so I wouldn’t assume the two dimensions are equal. These few operations can be also be filtered, rather than looped.
tell application "InDesign CS"'s document 1
if exists (links whose parent's effective ppi's item 1 < 100 and parent's effective ppi's item 2 < 100) then display dialog "Low res images in document."
end tell
It appears that EPS is now listed in the dicitionary, and maybe it wasn’t 11 years ago—I am not sure? Nevertheless, this makes me question if it is now possible for AS to return the effective ppi of a placed EPS.
With that being said, does anybody know how to retrieve an EPS link’s effective ppi, in a similar method used for a random link such as a JPEG or TIFF. (see snippet below)
Or maybe somebody can confirm that it is still impossible for Applescript to return the effective ppi or actual ppi of a placed EPS.
tell application id "com.adobe.InDesign"
tell active document
set effectiveDPI to effective ppi of parent of link 1
-- effective ppi returns a list of two values, the horizontal and vertical resolution
-- for our files (they are never disproportinate in their scaling), so I only need to get the first or second list item
set effectiveDPI to item 1 of effectiveDPI
display dialog effectiveDPI
end tell
end tell
InDesign stopped reporting raster EPS resolution since CS4 (whether in the Links panel or via AppleScript).
If you really need to get that resolution, you have two ways to do it via AppleScript:
-Read the EPS file, find %ImageData, then parse and calculate the appropriate values. Then get effective ppi according to the image scale in InDesign.
OR
-In InDesign, create a preflight profile that will flag any image (for example, by setting a ridiculously high min res requirement), run preflight, then read the results and locate the desired image.
Is your first suggestion referring to using “Image Events” to return the resolution? If so, that application does not seem to work with EPS files either in terms of returing its resolution.
Nevertheless, you confirmed that Applescript alone has no way of returning the effective resolution of a placed EPS graphic. Which is okay, I can still do other things like throw an alert when there is eccessive scaling, since most of our placed Photoshop EPS files are saved at 300 DPI. Therefore, I really only need to get the class of the link and if it is an EPS, then I will check if it is scaled more than 125 percent either horizontally or vertically. For the other raster file formats, I will alert based on the effective resolution.
No you’ll need to read the EPS file contents as string then extract values for physical and pixel dimensions from this portion and calculate the resolution: