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

Exporting to JPEG in CMYK not working (javascript)

New Here ,
Jan 18, 2017 Jan 18, 2017

Copy link to clipboard

Copied

Hi all,

I'm having a lot of trouble with an .AI script I'm making to export several versions of a file depending on it's color model.

The only thing holding me up is that I can't seem to set the color space to CMYK when exporting to JPEG, even though it is possible when choosing File / Export / Export as JPEG (jpg).

Here is my function

  1. // Exports a JPG 
  2. function exportJPG (filename, resolution, colorspace) { 
  3.  
  4.  
  5.   var options = new ExportOptionsJPEG(); 
  6.   options.antiAliasing = true
  7.   options.artBoardClipping = true
  8.   options.qualitySetting = 100
  9.   options.horizontalScale = (resolution / 72 * 100); 
  10.   options.verticalScale = (resolution / 72 * 100); 
  11.  
  12.  
  13.   if(colorspace === 'cmyk') { 
  14.     $.writeln('color space for JPG is ' + options.imageColorSpace); 
  15.     options.imageColorSpace = ImageColorSpace.CMYK; 
  16.     $.writeln('color space for JPG is now ' + options.imageColorSpace); 
  17.   } 
  18.  
  19.  
  20.   app.activeDocument.exportFile( new File(filename), ExportType.JPEG, options); 

I've got the writeln in there to try to debug, when I run it I get this in the console:

color model for JPG is undefined

color space for JPG is now ImageColorSpace.CMYK

and I get an RGB jpg.

Can anyone help? The scripting reference PDF is really lacking and it doesn't list this property, but it must exist. It would be bizarre if they made the export in scripting more limited than the file menu.

TOPICS
Scripting

Views

1.5K

Translate

Translate

Report

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
Community Expert ,
Jan 18, 2017 Jan 18, 2017

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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
Valorous Hero ,
Jan 19, 2017 Jan 19, 2017

Copy link to clipboard

Copied

That's right - the ExportOptionsJPG is related to the Save for Web function rather than the Export function.

Even with PNG, we have to use ImageCapture to be able to save a PNG with high resolution.

It's nice we can use Actions as a workaround, but not nice for having to do so in 1st place 😕

Votes

Translate

Translate

Report

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
New Here ,
Jan 24, 2017 Jan 24, 2017

Copy link to clipboard

Copied

LATEST

Thanks very much, Ten A.

It's good to know there's a community here, since the documentation and object model can be so confusing and lacking.

Votes

Translate

Translate

Report

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