Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Script for ExportForScreensOptionsJPEG() not working.

Advisor ,
Nov 21, 2021 Nov 21, 2021

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
1.3K
Translate
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

Community Expert , 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
...
Translate
Adobe
Community Expert ,
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.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
Translate
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
Advisor ,
Nov 21, 2021 Nov 21, 2021

@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

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

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

Hello @Charu Rajput,

 

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

 

Regards,

Mike

Translate
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
Community Expert ,
Mar 04, 2023 Mar 04, 2023
LATEST

Hi all, I know this is an old thread, but I just got this exact same 'TNAC' error while using ExportForScreens. The reason for the error is that scaleTypeValue = 400 is out-of-bounds. ScaleTypeValue is a simple scale factor, so if you want 400% scale, use scaleTypeValue = 4.

- Mark

Translate
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