Skip to main content
Inspiring
September 21, 2016
Question

Creating a jpeg preview from Illustrator file that contains slices

  • September 21, 2016
  • 2 replies
  • 661 views

I have an adobe add-on which uses the following extendscript  snippet to generate a JPEG preview from an illustrator file.

                var previewBasePath = "/Users/me/Desktop/";

               var previewName = "testexport";

                var type = ExportType.JPEG;

                var saveOptions = new ExportOptionsJPEG();

                saveOptions.artBoardClipping = true;

                saveOptions.qualitySetting = 80;

                saveOptions.horizontalScale = 200;

                saveOptions.verticalScale = 200;

                saveOptions.antiAliasing = true;

                saveOptions.optimization = false;

               

                var previewPath = previewBasePath + previewName + "_1.jpg";

                var file = new File( previewPath );

                app.activeDocument.exportFile(file, type, saveOptions);

However if the file contains "slices" it always outputs a folder full of files ( one for each slice ) which is not what I want.

If I action export from the FILE > EXPORT > EXPORT AS menu and use all of the default options, I get what I want which is a single jpeg.

Are there extra options for the jpeg export that control this or is there an alternative way to generate the JPEG?

Thanks in advance.

This topic has been closed for replies.

2 replies

CarlosCanto
Community Expert
Community Expert
September 22, 2016

how about using imageCapture?

var idoc = app.activeDocument;

var image = File('/c/temp/abcd.png');

var captureOpts = new ImageCaptureOptions;

captureOpts.matte = true;

captureOpts.antiAliasing = true;

idoc.imageCapture (image, idoc.artboards[idoc.artboards.getActiveArtboardIndex()].artboardRect,captureOpts);

Silly-V
Legend
September 21, 2016

If you use versions CS6+, you can use (script-generated) Actions to do this JPG export. Although, you could probably use app.executeMenuCommand("AISlice Delete All Slices") to delete the slices, do your script export and then do an Undo to bring the slices back.