Re: Check images in QX
Re: Check images in QX
- Subject: Re: Check images in QX
- From: Hans Haesler <email@hidden>
- Date: Tue, 4 Dec 2001 23:04:11 +0100
On Tue, 04 Dec 2001, Alberto Salvagnini wrote:
>
(...) In both cases I have to treat "missing" and "modified" at the
>
same way. I am watching the dictionary of QX to see how to get the state
>
("Status" in the check box where the picture are listed in QX) but I
>
still did not find it. Under "IMAGE" I found the file path, suppress
>
printing, also things I see in this check box, but nothing similar
>
to "State". Do you know where I can found this?
Alberto,
as you have remarked, with QXP 3.32 the path of a missing image is
shortened to the name of the volume and of the image file.
You could use this "problem" for testing if an image is missing
or not:
---
tell document 1 of application "QuarkXPress(TM)"
set oD to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
tell current box
tell image 1
set imgPath to (get file path) as text
if (count of text items of imgPath) is less than 3 then
display dialog "The image file is missing." buttons "OK" default button 1
else
display dialog "The image file is okay." buttons "OK" default button 1
end if
end tell
end tell
set AppleScript's text item delimiters to oD
end tell
---
This works -- as long as the images are in a folder and not on the
root level of your harddisk or of a volume of the server. But it would
definitely break when you run it with QXP 4.11 (because the entire
file path is returned, even of missing image files).
Therefore it would be better to use another solution which tells you
as well if an image file is modified. But don't use the "Finder".
The 'info for' of the Standard Additons is faster.
The repeat loop looks at each picture box (this is faster than asking
for a list of 'every image 1 whose bounds is not {0, 0, 0, 0}').
If there is a file path (else it would be a pasted PICT), the
variable 'imgPath' is set to it and the variable 'QXPDate' is set to
the modification date which is stored in the QXP document. Inside of
the following try wrapper the handler which gets the modification
date of the image file is called. This must happen outside of the
QXP loop. If the modification dates are not matching, then the image
file is modified. The only reason for an error is when the modification
date can't be obtained because the image is... missing.
Initialize lists...
set missList to {}
set modList to {}
... and replace the dialogs below by commands which store the file names
(set end of missList to imgName) when there is a problem.
At the end of the script, when any of the lists counts one item or
more, you can write it to a report or whatever.
---
tell document 1 of application "QuarkXPress(TM)"
activate
set n to count of picture boxes
if n is greater than 0 then
set oD to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
repeat with i from 1 to n
if (bounds of image 1 of picture box i) is not {0, 0, 0, 0} then
if (file path of image 1 of picture box i) is not null then
tell image 1 of picture box i
set imgPath to (get file path) as text
set imgName to last text item of imgPath
set QXPDate to modification date
end tell
try
set fileDate to my getModDate(imgPath)
if QXPDate is not fileDate then
display dialog "The image file " & imgName & "
is modified." buttons "OK" default button 1 with icon 2
end if
on error
display dialog "The image file " & imgName & "
is missing." buttons "OK" default button 1 with icon 2
end try
else
display dialog "This is a pasted PICT.
There is no image file." buttons "OK" default button 1 with icon 2
end if
end if
end repeat
set AppleScript's text item delimiters to oD
end if
end tell
on getModDate(imgPath)
modification date of (info for file imgPath)
end getModDate
---
BTW, this is a modified excerpt from my script which checks the QXP
documents. Here, every layouter uses it, _before_ copying his document
in the hot-folder of the PDF workflow...
---
Hans Haesler <email@hidden>