AI scripting export to jpeg, Antialiasing Type Optimized

New Here ,
Sep 06, 2020 Sep 06, 2020

Copy link to clipboard

Copied

Hi,

 

I have a javacript to export hundreds, or even thousands of SVG-files to JPEG.

 

However, I cant find the JPEG setting to get antialiasing Art Optimised or Type Optimized.

 

optionsJPEG.antiAliasing is according to spec only a boolean.

 

Please someone guide me to a workaround.

 

regards Ola

 

 

TOPICS
Bug, Import and export, Scripting

Views

219

Likes

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

correct answers 1 Correct Answer

Adobe Community Professional , Sep 06, 2020 Sep 06, 2020
Hi, Try following snippet by Carlos // export selection by Resolution // carlos canto - 06/27/2020 // https://community.adobe.com/t5/illustrator/export-jpg-as-300-ppi/td-p/11244200?cid=101&cgid=18269&page=1 function main() { var idoc = app.activeDocument; var asset = idoc.assets.addFromSelection(); asset.assetName = 'myExportedAsset'; var destFolder = Folder('~/desktop'); var resolution = 300; exportItem (asset, destFolder, resolution); var destPath = destF...

Likes

Translate

Translate
Adobe Community Professional ,
Sep 06, 2020 Sep 06, 2020

Copy link to clipboard

Copied

Hi,

Try following snippet by Carlos

// export selection by Resolution
// carlos canto - 06/27/2020
// https://community.adobe.com/t5/illustrator/export-jpg-as-300-ppi/td-p/11244200?cid=101&cgid=18269&page=1

function main() {
    var idoc = app.activeDocument;
    var asset = idoc.assets.addFromSelection();
    asset.assetName = 'myExportedAsset';
    
    var destFolder = Folder('~/desktop');
    var resolution = 300;
    exportItem (asset, destFolder, resolution);
    
    var destPath = destFolder + '/mySaveAsFile.jpg';
    exportFileToJPEG (destPath, resolution);
}

function exportItem(item, destFolder, resolution) {
    // turn create folders off, same as unchecking the setting on the UI Export Assets window
    app.preferences.setIntegerPreference ('plugin/SmartExportUI/CreateFoldersPreference', 0); // don't create subfolders
    
    var whatToExport = new ExportForScreensItemToExport();
    whatToExport.assets = [item.assetID];
    whatToExport.artboards = ''; // don't export artboard
    whatToExport.document = true; // don't export document

    var jpgOptions = new ExportForScreensOptionsJPEG;
    jpgOptions.antiAliasing = AntiAliasingMethod.ARTOPTIMIZED; // art optimized results in jagged edges, is it a bug?
    jpgOptions.compressionMethod = JPEGCompressionMethodType.BASELINEOPTIMIZED; // BASELINESTANDARD
    jpgOptions.scaleType = ExportForScreensScaleType.SCALEBYRESOLUTION;
    jpgOptions.scaleTypeValue = resolution;
    
    activeDocument.exportForScreens (destFolder, ExportForScreensType.SE_JPEG100, jpgOptions, whatToExport);
}

main();

function exportFileToJPEG (dest, resolution) {
    
    var exportOptions = new ExportOptionsJPEG();
    var type = ExportType.JPEG;
    var fileSpec = new File(dest);
    exportOptions.antiAliasing = true;
    exportOptions.artBoardClipping = false;
    exportOptions.horizontalScale = resolution*100/72; // scaling increases image physical size, 
    exportOptions.verticalScale = resolution*100/72;
    exportOptions.qualitySetting = 100;
    app.activeDocument.exportFile( fileSpec, type, exportOptions );
}

 

For more reference please read following thread

https://community.adobe.com/t5/illustrator/export-jpg-as-300-ppi/m-p/11244323?page=1#M183146

Best regards

Likes

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
Enthusiast ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

how can get real 100o pixels with, i cant see to figure this part out. I tried using the above script or part of it to scale it to 1000dpi, still my pixel document dimensions are low. i tried adding the function which calculates the scale ratio, but then i bump into a scale limit.

 

Im going nuts here, the documents up to 2021 are not updated with info about ExportForScreen properly. The export for screen has the option of width and height as a value, but in the scripting it is referenced as horizontal scale and vertical scale. 

 

Does anyone know how to add the save options for these? 

Likes

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 Professional ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

LATEST

Likes

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