Re: Determine whether spot color is RGB or CMYK in Illustrator CS2
Re: Determine whether spot color is RGB or CMYK in Illustrator CS2
- Subject: Re: Determine whether spot color is RGB or CMYK in Illustrator CS2
- From: Stephan Peterson <email@hidden>
- Date: Fri, 18 May 2007 15:59:22 -0500
After much banging of my head against the wall I finally have a
solution. Unfortunately, it doesn't involve the scripting of
Illustrator due to an apparent bug.
A little background:
I have a script that receives AI CS1 files from users that I need to
open in AI CS2 and save out as a PDF using specific settings. The
resulting PDF is given to a system called Prinergy that does a
conversion by applying a few ICC profiles and the result is a PDF/
X-1A:2001 compliant file. I pick that file up and give it back to the
user. Easy enough. What I ran into is that some of the files coming
thru had RGB spot colors in them because of old template files that
didn't have them removed. That's being addressed, but I thought it'd
be good to add a check to my script to catch the RGB spots and kick
the job back to the user so that they could fix it. If the file with
an RGB spot goes into Prinergy it can't be processed because PDF/X-1A:
2001 doesn't allow RGB spots as a part of its standard. The file will
get "stuck" in Prinergy and never come out the other end. It's really
annoying, so catching the RGB spot up front is the best solution.
Anyway, with the on and off-list help of Shane Stanley, Simon Topliss
and Wayne Melrose I determined that CS2 incorrectly reports the class
of an RGB spot color in a CMYK mode document as being "CMYK color
info" instead of "RGB color info". If the document is opened in CS1
there's a warning about the document being of mixed mode. No such
warning is given by CS2. Anyway, here's the code to examine a spot
color and attempt to determine if its of the CMYK or RGB variety:
tell application "Adobe Illustrator CS2"
tell document 1
spot 2's color
end tell
end tell
Here's the result:
{class:CMYK color info, cyan:96.078425645828, magenta:
31.764703989029, yellow:1.568627357483, black:13.333332538605}
I can assure you that the spot is an RGB and not a CMYK as is being
reported.
One suggestion that looked promising but didn't pan out was the
following (based on code from Simon):
tell application "Adobe Illustrator CS2"
tell current document
repeat with spotIndex from 1 to count of spots
if name of spot spotIndex does not contain "Registration" then
set spotColor to color of spot spotIndex
set color of spot spotIndex to {class:CMYK color info, cyan:cyan
of spotColor, magenta:magenta of spotColor, yellow:yellow of
spotColor, black:black of spotColor}
end if
end repeat
end tell
end tell
This looked like it was going to work, but there were instances where
certain colors didn't handle the "conversion" properly. I abandoned
this approach because I didn't want to risk accidentally changing the
users files. I really wanted to just detect the RGB spots and put the
responsibility to change them back on the user.
On the advice of a co-worker I explored just opening the file in a
text editor like Text Wrangler and seeing if by chance I could from
any text in the document if RGB sptos were present. BINGO! In the
comments/header at the beginning there's a "%%RGB Custom Color:"
entry that's present if RGB spots exist in the document. This lead me
to the following code for determining and RGB spot colors presence:
set theFile to "path:to:the:file.ai"
-----
set theText to read file theFile
-----
if theText contains "%%RGBCustomColor:" then
set containsRGB to true
else
set containsRGB to false
end if
BTW, this also works on PDF files saved out from Illustrator.
I verified that this bug is also present in Illustrator CS3.
Thanks again to Shane, Simon and Wayne for their assistance.
Stephan
On May 15, 2007, at 1:57 PM, Stephan Peterson wrote:
I can't this to work either.
Stephan
On May 10, 2007, at 11:03 AM, Wayne Melrose wrote:
On 10. mai. 2007, at 18.00, stephan peterson wrote:
This isn't working either. I tried this and the spot doesn't
change from
RGB to CMYK as I was assuming it would. When I look at what
colorType is
getting set to it's "CMYK color info".
Stephan
And to answer you're actual question, try this:
tell swatch -1
if class of color is spot color info then
-- need to get class of the spot it's based on
set colorType to class of color of spot of color
else
set colorType to class of color
end if
end tell
--
Shane Stanley <email@hidden>
AppleScript Pro Denver, June 2007 <http://scriptingmatters.com/
aspro>
Stephen,
I spoke to Shane about this issue off list, he's fast asleep right
now down in Oz, although this is what he told me, the code you
have snipped out here only gives you the class of the colour, to
change it, Shane suggested this code (below), although advised
that this is not tested.
tell swatch -1
if class of color is spot color info then
-- need to get class of the spot it's based on
set colorType to class of color of spot of color
if colorType is RGB color info then
set class of color of spot of color to CMYK
color info
end if
else
set colorType to class of color
if colorType is RGB color info then
set class of color to CMYK color info
end if
end if
end tell
He also mentioned that to get AI to open a file forcing options
etc, you must first turn off dialogs, I don't have that code at
the moment, but I'm sure if you Google it or look on the archives
you'll find something..
Hope that Helps
Wayne Melrose
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40goofybastard.com
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden