【问题标题】:InDesign - How to export groups to jpgInDesign - 如何将组导出为 jpg
【发布时间】:2020-02-13 00:01:48
【问题描述】:

我需要将 InDesign 中的组导出为 jpg。

我的小组将包含一张图片、徽标和一些 txt,以及 我需要为文档中的每个组提供一个图像。最好是图片的名字。

我尝试使用this script, 但是它只处理图像而不是组。

我想让脚本使用组而不是图像。

exportSelectedImages();

function exportSelectedImages() {
    // configure export settings
    app.jpegExportPreferences.exportResolution = 72;
    app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;

    // collect selected objects
    var selected = app.activeDocument.selection;
    $.writeln("Got " + selected.length + " selected objects...");

    // process selected objects
    for (var i = 0; i < selected.length; i++) {
        var cursor = selected[i];
        var img = cursor.images;

        $.writeln("Processing #" + (i+1) + "/" + selected.length);
        $.writeln("\t Type: " + cursor.constructor.name);

        // verify if object contains an image or not
        if (cursor.images.length > 0) {     
            var img = cursor.images[0];
            $.writeln("\t Contains image of type " + img.imageTypeName);
            var imageFileName = cursor.images[0].itemLink.name;
            $.writeln("\t File Name: " + imageFileName);
        } else {
            $.writeln("\t Not an image");
        }

        // save the object to a jpeg in path specified below
        var myFile = new File('~/Desktop/jowjow/' + "crop_" + imageFileName + '.jpg');
        cursor.exportFile(ExportFormat.JPG, myFile);

     }

    $.writeln("Done.");
}

【问题讨论】:

    标签: export jpeg adobe-indesign


    【解决方案1】:

    选择组后试试这个代码:

    app.jpegExportPreferences.exportResolution = 72;
    
    app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;
    
    var selected = app.activeDocument.selection;
    
    for (var i = 0; i < selected.length; i++) {
    
        if(cursor.constructor.name == "Group"){
    
            var cursor = selected[i];
    
            if(cursor.rectangles.length == 1){
    
                if (cursor.rectangles[0].graphics.length > 0) {
    
                    var img = cursor.rectangles[0].graphics[0];
                    var imageFileName = cursor.rectangles[0].graphics[0].itemLink.name;
                    var myFile = new File('~/Desktop/' + "Group_" + imageFileName + '.jpg');
                    cursor.exportFile(ExportFormat.JPG, myFile);
                    }
                }
            }
        }
    alert("Process Completed!!!");
    

    苏尼尔

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多