3 Replies Latest reply on Jan 24, 2017 11:11 AM by Stephen Engert

    Exporting to JPEG in CMYK not working (javascript)

    Stephen Engert

      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.