hi,
i wan’t a script that prompts for a quark file, and then takes that file, and counts the points of the clipping path on every image, and then makes a log with them ( filename.ext - 102 points, for example ).
i couldn’t find the quark dictionary in the applescript dictionary, so i don’t know how to begin…
where could a i get the list of comands for quark?
thanks to all.
marto.
EDIT: in fact… if any other program, such as Photoshop, can count the points in a path, it also works for me ( i could just tell the script to analyze all files in the folder from wich Quark loads the images… so it would be the same… i guess )
Model: PPCG4 400mhz
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
Don’t have quark on this machine, so had to look at your second option “Photoshop”
This will tell you how many points are in a open photoshop document that has a path.
tell application "Adobe Photoshop CS"
activate
set x to properties of entire path of path item 1 of document 1
set y to entire sub path of x
count y
end tell
--> Number of points in the path
Hopefully you can work with this, i’ll try and have a look at points in quark when
i get onto a machine that has it…
This should be close ish to what you want using Photoshop. I don’t think you can do what you want in Quark but don’t hold me to that.
set Infolist to {}
set inputFolder to choose folder with prompt "Where is your image folder?" without invisibles
tell application "Finder"
set filesList to files in inputFolder
end tell
repeat with aFile in filesList
set fileIndex to 0
tell application "Finder"
set theFile to aFile as alias
set theFileName to name of theFile
end tell
tell application "Adobe Photoshop CS"
activate
set display dialogs to never
open theFile
set docRef to the current document
set docName to name of docRef
tell docRef
if exists (path items whose kind is clipping) then
set thepath to (name of every path item whose kind is clipping)
set thepath to item 1 of thepath
set thepoints to count items of entire sub path of entire path of path item thepath
else
set thepath to "No Clipping Path"
set thepoints to "0"
end if
end tell
close current document without saving
end tell
set Infostring to docName & " - " & thepath & " - " & thepoints & " Points" as string
copy Infostring to end of Infolist
end repeat
-- Set your list to text file
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set Infolist to items of Infolist as text
set AppleScript's text item delimiters to ASTID
-- Creating a report file
set ReportFile to ((path to desktop folder) as text) & "Image Path Points Info" & ".txt"
set RF to open for access file ReportFile with write permission
try
set eof of RF to 0
write Infolist to RF
close access RF
on error
close access RF
end try
thanks!!!
i’m having a problem that i can’t solve with the script… it seems to timeout… i don’t know if its photoshop, or what, but at some point, it stops responding…
i’ve serched for a similar way of doing this with imagemagick, but i can’t find any command to read path elements…
Imageready can’t do it, or at least, i can’t find any references to paths in the Dictionary either…
any ideas?
(( i run a PPC G4 400mhz, with 768RAM; but i also tried the script in a G5, with 1gb ram, and it also stops responding… ))
thanks to all!!!
this is my modified code…
set inputFolder to choose folder with prompt "Seleccione la carpeta de imagenes" without invisibles
tell application "Finder"
set filesList to files in inputFolder
end tell
try
repeat with aFile in filesList
tell application "Finder"
set theFile to aFile as alias
set theFileName to name of theFile
end tell
tell application "Adobe Photoshop CS2"
activate
set display dialogs to never
open theFile
set docRef to the current document
set docName to name of docRef
tell docRef
if exists (path items whose kind is clipping) then
set thepath to (name of every path item whose kind is clipping)
set thepath to item 1 of thepath
set thepoints to count items of entire sub path of entire path of path item thepath
else
set thepath to "Sin Clipping Path"
set thepoints to "0"
end if
end tell
close current document without saving
end tell
my writelog(docName, thepath, thepoints)
end repeat
on error err
display dialog err
end try
on writelog(docName, thepath, thepoints)
set theLog to ((path to desktop folder) as text) & "PointLog.txt"
try
open for access file the theLog with write permission
write (return & docName & " - " & thepath & " - " & thepoints & " Points") to file the theLog starting at eof
close access file the theLog
on error
try
close access file the theLog
end try
end try
end writelog
Your script works just fine for me so Im not sure what the issue is. It may be down to you using CS2 which I don’t have but there could be small modifications to some of the syntax between these apps. I like the handler one day I will work out how these work. Adding to the end of log is something I had been looking for. So thanks for that part much neater.
well… if it is a part of the syntax, then the script shouldn’t run at all…
but it works, on some files. on some testing files, with clipping path, photoshop just stops responding for no apparent reason. my test files are all Tiffs in CMYK, so there is no issue with file type or any other setting…
the number of points of the files that go through the script is less than 250… but more of that, tilts the script.
and my script is intented to determine wich files have more than 1000 points… so for now, its a little useless…
any ideas? thnx.
and no, thank you Mark67!!! if you took something from my script, that was the first time i’m usefull to someone at AP, so thanks!!!
Ah, just got it to choke. Ran some files with paths converted from selections so they are point heavy well over a 1000 or so. I can now have a look at whats going wrong if I find out i will post back.
I know only a couple weeks ago I had a catalogue to print to PS then PDF. Out of about 3000 images about a dozen images had paths created this way. Quark will crash out when making PS if clipping paths are this heavy.
there seems to be something like “path ponit info”, that could have the number of items ( points ) in it, and thus, the scrpt won’t have to make Photoshop count for them… that way, it might work no matter what number of points the file has…
but i can’t understand how it works…
another thing that would be great, is to hide Photoshop while it does the script… i’ve read thea inDesign is able to hide, may be Photoshop’s able too.
btw: isn’t there any other program that can manage paths? imageReady can’t, imagemagick neither…
There is path points & anchor and I have tried to do this with no luck. To be honest paths are just about the worst thing in Photoshop to deal with every time it just throws back errors. I know of nothing else that can deal with paths either. Acrobat has open with invisible but I have not seen this in Photoshop.
yep! I’ve asked over in the Photoshop forum about this to see if the same issue arises in JS or VB. Or if this info can be pulled from the script listener plug-in. Image Events is a no go I think as it don’t do EPS and I can’t see paths in there.
yes. i had problems with imageevents and its supported file types… thats why i had to use imagemagic with ghostscript, just to get support for tiffs, pcds, eps ( illustrator and photoshop ) and jpeg ( all in CMYK and RGB )…
but the only program i know that works with paths, is photoshop…
It looks like AS is having a problem counting the items of the list in some test files Java is returning the count in a fraction of a second where as Applescript is taking over 60 seconds. You could put the count call in an increased time out block. I’ve also tried changing the count line to:
set thepoints to count (items of path points of every sub path item of path item thepath)
Here are 2 bits of code that I tried some tests with. Note the Java here is only for the first sub path of path item so my test files only have 1 sub item
tell application "Adobe Photoshop CS"
activate
set docRef to the current document
tell docRef
if exists (path items whose kind is clipping) then
set clippath to (index of every path item whose kind is clipping)
set clippath to item 1 of clippath
end if
set i to clippath - 1 -- Java's index starts at "0" Zero
tell application "Extra Suites"
ES start timer
end tell
do javascript "activeDocument.pathItems[" & i & "].subPathItems[0].pathPoints.length" show debugger on runtime error
set pathpoints to the result as string
tell application "Extra Suites"
set mytime to (ES stop timer) as string
end tell
display dialog mytime
end tell
end tell
tell application "Adobe Photoshop CS"
activate
set docRef to the current document
tell docRef
tell application "Extra Suites"
ES start timer
end tell
if exists (path items whose kind is clipping) then
set thepath to (name of every path item whose kind is clipping)
set thepath to item 1 of thepath
set thepoints to count (items of path points of every sub path item of path item thepath)
end if
end tell
tell application "Extra Suites"
set mytime to (ES stop timer) as string
end tell
display dialog mytime
end tell
This may help at least it doesn’t time out with any paths that i’ve tested. Hopefully with the right code for the JS you won’t need the repeat in subpaths loop but untill then you could test this out.
tell application "Adobe Photoshop CS"
activate
set docRef to the current document
tell docRef
if exists (path items whose kind is clipping) then
set clippath to (index of every path item whose kind is clipping)
set clippath to item 1 of clippath
set subpaths to count of sub path items of path item clippath
end if
set i to clippath - 1 -- Java's index starts at "0" Zero
tell application "Extra Suites"
ES start timer
end tell
set thepoints to 0
repeat with x from 0 to (subpaths - 1) -- Java's index starts at "0" Zero
do javascript "activeDocument.pathItems[" & i & "].subPathItems[" & x & "].pathPoints.length" show debugger on runtime error
set pathpoints to the result as string
set thepoints to thepoints + pathpoints as string
end repeat
display dialog thepoints
tell application "Extra Suites"
set mytime to (ES stop timer) as string
end tell
display dialog mytime
end tell
end tell
i’ve tried the javascript thingie… it works GREAT! but i don’t understand what is different with it… i mean… what is the script counting? every point in one path of a file? thus, if the file has more than one path, it won’t be counted?
if thats the case, its allright, because i only need one path per file…
so, if thats done, then i’m TERRIBLY thankfull!!! this is a VERY usefull tools for my office!!!
marto, its only counting the total of all the path points in the “clipping path” the sub paths are if your clipping path was made up of multiple paths for example if it had holes cut through it like a ring donut. I hope that makes sence.