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

Can you help me modify the script thank you

Explorer ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

Refer to the script code below and modify it to export jpg to the current ai file path. Export according to the drawing board. Resolution 150

 

 

 

 

 

var pngPath = activeDocument.fullName.toString();
pngPath = pngPath.substring(0,pngPath.lastIndexOf("."));
exportFileToPNG24(pngPath);
function exportFileToPNG24 (dest) {
if ( app.documents.length > 0 ) {
var exportOptions = new ExportOptionsPNG24();
var type = ExportType.PNG24;
var fileSpec = new File(dest);
exportOptions.antiAliasing = false;
exportOptions.transparency = false;
exportOptions.artBoardClipping = true;
exportOptions.saveAsHTML = true;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}




if ( app.documents.length > 0 ) {
var doc = app.activeDocument;
for(i=0;i<doc.artboards.length;i++){
var pngPath = activeDocument.fullName.toString();
pngPath = pngPath.substring(0,pngPath.lastIndexOf("."))+doc.artboards[i].name;
doc.artboards.setActiveArtboardIndex(i);
exportFileToPNG24(pngPath);
}

function exportFileToPNG24 (dest) {
var exportOptions = new ExportOptionsPNG24();
var type = ExportType.PNG24;
var fileSpec = new File(dest);
exportOptions.antiAliasing = false;
exportOptions.transparency = false;
exportOptions.artBoardClipping = true;
exportOptions.saveAsHTML = true;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}

TOPICS
Scripting

Views

359

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

Community Expert , Jul 27, 2020 Jul 27, 2020

Hi,

To add more information, imageCapture only works to export into PNG format. For JPEg, please refer the link below

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

Votes

Translate

Translate
Adobe
Community Beginner ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

Hello,
the script does not know how to set DPI
you can call a third-party utility
or call Action (but there are subtleties)

 

var pngPath = activeDocument.fullName.toString();
pngPath = pngPath.substring(0,pngPath.lastIndexOf("."));

exportFileToJPEG(pngPath);

function exportFileToPNG24 (dest) {
  if ( app.documents.length > 0 ) {
    var exportOptions = new ExportOptionsPNG24();
    var type = ExportType.PNG24;
    var fileSpec = new File(dest);
    exportOptions.antiAliasing = false;
    exportOptions.transparency = false;
    exportOptions.artBoardClipping = true;
    exportOptions.saveAsHTML = true;
    app.activeDocument.exportFile( fileSpec, type, exportOptions );
  }
}

function exportFileToJPEG (dest) {
  if ( app.documents.length > 0 ) {
    var exportOptions = new ExportOptionsJPEG();
    var type = ExportType.JPEG;
    var fileSpec = new File(dest);
    exportOptions.antiAliasing = false;
    exportOptions.qualitySetting = 100;
    exportOptions.horizontalScale = 100;
    exportOptions.verticalScale = 100;
    exportOptions.artBoardClipping = true;
    app.activeDocument.exportFile( fileSpec, type, exportOptions );
  }
}



if ( app.documents.length > 0 ) {
  var doc = app.activeDocument;
  for (i = 0; i < doc.artboards.length; i++) {
    var pngPath = activeDocument.fullName.toString();
    pngPath = pngPath.substring(0, pngPath.lastIndexOf(".")) + doc.artboards[i].name;
    doc.artboards.setActiveArtboardIndex(i);
    exportFileToJPEG(pngPath);
  }
}

 

 

 

Votes

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
Explorer ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

Hello, thank you very much for your help. It would be great if you can set up DIP or who would hope to help me. Thank you very much

Votes

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
Explorer ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Here is another post with answer how to set dpi settings.
So your code will be something like this:

if ( app.documents.length > 0 ) {
  for (i = 0; i < doc.artboards.length; i++) {
    var Path = activeDocument.fullName.toString();
    Path = Path.substring(0, Path.lastIndexOf(".")) + doc.artboards[i].name + ".jpg";
    doc.artboards.setActiveArtboardIndex(i);
    var activeAB = doc.artboards[doc.artboards.getActiveArtboardIndex()];
    exportFile(Path);
  }
}

function exportFile (dest) {
      var exportOptions = new ImageCaptureOptions();
      var fileSpec = new File(dest);
      exportOptions.antiAliasing = true;
      exportOptions.resolution = 150;
      doc.imageCapture( fileSpec, activeAB.artboardRect, exportOptions );
  }

 

Votes

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
Explorer ,
Jul 27, 2020 Jul 27, 2020

Copy link to clipboard

Copied

Thank you

Votes

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
Community Expert ,
Jul 27, 2020 Jul 27, 2020

Copy link to clipboard

Copied

LATEST

Hi,

To add more information, imageCapture only works to export into PNG format. For JPEg, please refer the link below

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

Best regards

Votes

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