Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Script for ExportForScreensOptionsJPEG() not working.

Advocate ,
Nov 21, 2021 Nov 21, 2021

Copy link to clipboard

Copied

Hello,

 

I've been trying to get the below code to work from the post below, but I just can't figure it out....any ideas??

Error Code# 1200: an Illustrator error occurred: 1128353364 ('TNAC') @ file

https://community.adobe.com/t5/illustrator-discussions/export-for-screens-exporting-multiple-documen...

 

var doc = app.documents[0];

var myFolder = activeDocument.path;

var assets = doc.assets; 

var whatToExport = new ExportForScreensItemToExport();

whatToExport.artboards = '1-2';

whatToExport.document = true;

var jpegParam = new ExportForScreensOptionsJPEG();

jpegParam.compressionMethod = JPEGCompressionMethodType.PROGRESSIVE;

jpegParam.progressiveScan = 4;

jpegParam.antiAliasing = AntiAliasingMethod.None;

jpegParam.embedICCProfile = true;

jpegParam.scaleType = ExportForScreensScaleType.SCALEBYWIDTH;

jpegParam.scaleTypeValue = 400;

path = new File(myFolder + "/" + "_thumbs" + ".jpg");

doc.exportForScreens(path, ExportForScreensType.SE_JPEG100, jpegParam, whatToExport, "JPEG100_");

 

 

Thanks in advance!

Regards,

Mike

 

TOPICS
Scripting

Views

82

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 , Nov 21, 2021 Nov 21, 2021
Hi Mike, Try the following script it will work var doc = app.documents[0]; var myFolder = activeDocument.path; var assets = doc.assets; var whatToExport = new ExportForScreensItemToExport(); whatToExport.artboards = '1-2'; whatToExport.document = true; var jpegParam = new ExportForScreensOptionsJPEG(); jpegParam.compressionMethod = JPEGCompressionMethodType.PROGRESSIVE; jpegParam.progressiveScan = 4; jpegParam.antiAliasing = AntiAliasingMethod.None; jpegParam.embedICCProfile = true; jpegParam.sc...

Likes

Translate

Translate
Adobe Community Professional ,
Nov 21, 2021 Nov 21, 2021

Copy link to clipboard

Copied

Hi Mike,

Try the following script it will work

var doc = app.documents[0];
var myFolder = activeDocument.path;
var assets = doc.assets;
var whatToExport = new ExportForScreensItemToExport();
whatToExport.artboards = '1-2';
whatToExport.document = true;
var jpegParam = new ExportForScreensOptionsJPEG();
jpegParam.compressionMethod = JPEGCompressionMethodType.PROGRESSIVE;
jpegParam.progressiveScan = 4;
jpegParam.antiAliasing = AntiAliasingMethod.None;
jpegParam.embedICCProfile = true;
jpegParam.scaleType = ExportForScreensScaleType.SCALEBYWIDTH;
jpegParam.scaleTypeValue = 400;
var path1 = new File(myFolder + "/" + "_thumbs" + ".jpg");
doc.exportForScreens(path1, ExportForScreensType.SE_JPEG100, jpegParam, whatToExport);

 

The error that you have received may be of the following reasons

1. You don't have 2 artboards in the document as you mention artboards="1-2". Make sure to have two artboards.

2. Last parameter in the exportForScreens is not required.

 

I hope it help you.

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
Advocate ,
Nov 21, 2021 Nov 21, 2021

Copy link to clipboard

Copied

@Charu Rajput,

 

Thank you! I'm not sure why it wasn't working as the document has 2 artboards and I tried removing the Last parameter in the exportForScreens, but it's working now.

Question: do you know why the "_thumbs" that's hard coded for the output file naming wouldn't be honored?? I had to create a work around by having the script rename the artboards before the export and rename the back afterwards.

 

Regards,

Mike

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 ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

Hi Mike,

exportForScreens expect first parameter as exportFolder, where assets will be exported, that's why it won't consider _thumb.jpg name. But you can add the suffix to the exporte file by passing the string as a last parameter. See below code.

var doc = app.documents[0];
var myFolder = activeDocument.path;
var assets = doc.assets;
var whatToExport = new ExportForScreensItemToExport();
whatToExport.artboards = '1-2';
whatToExport.document = true;
var jpegParam = new ExportForScreensOptionsJPEG();
jpegParam.compressionMethod = JPEGCompressionMethodType.PROGRESSIVE;
jpegParam.progressiveScan = 4;
jpegParam.antiAliasing = AntiAliasingMethod.None;
jpegParam.embedICCProfile = true;
jpegParam.scaleType = ExportForScreensScaleType.SCALEBYWIDTH;
jpegParam.scaleTypeValue = 400;
var path1 = new File(myFolder);
doc.exportForScreens(path1, ExportForScreensType.SE_JPEG100, jpegParam, whatToExport, '_thumb_');

 

So, whatever will be exported from the above script will have _thumb_ as a prefix to the exported file.

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
Advocate ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

LATEST

Hello @Charu Rajput,

 

Yes, the last parameter adds _thumb_ as a prefix but how would you add it as the suffix?

 

Regards,

Mike

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