Highlighted

AI scripting export to jpeg, Antialiasing Type Optimized

New Here ,
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

38

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

AI scripting export to jpeg, Antialiasing Type Optimized

New Here ,
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

39

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
Adobe Community Professional ,
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
Reply
Loading...