1 Reply Latest reply on Jan 18, 2017 9:06 AM by A. Patterson

    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


      // Exports a JPG
      function exportJPG (filename, resolution, colorspace) {
        var options = new ExportOptionsJPEG();
        options.antiAliasing = true;
        options.artBoardClipping = true;
        options.qualitySetting = 100;
        options.horizontalScale = (resolution / 72 * 100);
        options.verticalScale = (resolution / 72 * 100);
        if(colorspace === 'cmyk') {
          $.writeln('color space for JPG is ' + options.imageColorSpace);
          options.imageColorSpace = ImageColorSpace.CMYK;
          $.writeln('color space for JPG is now ' + options.imageColorSpace);
        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.