Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to read file color Mode of a illustrator document

Participant ,
Mar 13, 2011 Mar 13, 2011

Hii!!

i'm trying to make a script for a batch process.

If a file is in RGB mode then it has a set of sequence to run on.

If its a CMYK mode file then it should execute another set of sequence.

But i cant filter the file mode..

anyone pls help me on this..

TOPICS
Scripting
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Advocate ,
Mar 13, 2011 Mar 13, 2011

DocumentColorSpace tells you the color mode.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 13, 2011 Mar 13, 2011

Hi Jong,

i tried this but it returns "undefined".

var newcolor = activeDocument.DocumentColorSpace
alert (newcolor)

i think i made mistake on this

pls check and rectify my error

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 14, 2011 Mar 14, 2011

DocumentColorSpace is the name of the enumeration. The Document property is called "documentColorSpace"; for a DocumentPreset, it's called "colorMode" (see a system here?).

Of course, the documentation should have told you that -- in the CS4 guide, it's from p. 36 onwards.

var newcolor = activeDocument.documentColorSpace;

alert (newcolor);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 14, 2011 Mar 14, 2011

Sorry what I posted is ONLY meant to be used with native Illustrator files '.ai' else it will loop endlessly… It just reads a File comment string… EPS are old, fat and overly complex for me to bother with… almost any app can create them and they can contain the kind of data I could never sift thru… if I had years to try… I would do as Jong has suggested and open the file to see the mode… However an RGB eps can contain CMYK postscript data and thats where it all starts to become a bit fuzzy…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2011 May 06, 2011

Hello Mark,

"%%DocumentProcessColors:  Black"

     -----This is the comment if the file documents is in black and white

"%%DocumentProcessColors:  Cyan Magenta Yellow Black"

     -----This is the comment if the file documents is in CMYK

And for RGB this comment is missing.

How can i make your script to check these conditions?

help me on this pls.

Thanks in advance.

Praveen

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 06, 2011 May 06, 2011

The comment could be… Any combination of the 4 process colours used or none if its empty or white. The colour mode is in a similar comment with a 1 or 0 to indicate CMYK or RGB.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2011 May 06, 2011

Ya, u are right... but eps files dont have "colour mode" its only for ai files.

Can we utilize "%%DocumentProcessColors:" comment for eps files..??

if file.readin() = "%%DocumentProcessColors:  Black" is true then it should return black

if file.readin() = "%%DocumentProcessColors:  Cyan Magenta Yellow Black" is true then it should return CMYK

if file.readin() = "%%DocumentProcessColors:" is null then it should return RGB

is it possible?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 07, 2011 May 07, 2011

With Illustrator EPS the files can be RGB or CMYK… Only files pre version 9 can contain both and if you open these you will be prompted to force to one or the other color modes. That said with RGB files there is a save option to include CMYK postscript if this is true then the line %%DocumentProcessColors: will exist in the comments if false it will not and the posted function should return null… Remember this list is the process separations and only the ones that are used…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 07, 2011 May 07, 2011
LATEST

Thanks Mark,

I have my eps file created with Illustrator CS2 and those not included with CMYK postscript. So the eps files of CMYK mode have %%DocumentProcessColors: and the RGB moded files dont have this comment.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 13, 2011 Mar 13, 2011

If it is Illustrator .ai files that you are dealing with then this may help…

var f = new File('~/Desktop/SomeFile.ai'); alert(aiMode(f)); function aiMode(f) {      var mode = null;           f.open('r');      do {           var line = f.readln();      } while (!/^%AI\d_ColorModel: [1-2]/.test(line));      var m = line.match(/\d$/g);           m == 1 ? mode = 'RGB' : mode = 'CMYK';      f.close();      return mode; }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 13, 2011 Mar 13, 2011

Thanks lot Mark.. its works the best with "*.ai" files.

but i'm on "*.eps" files. it cant read its data.

could u pls help me..

Manythanks in advance..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines