0

I would like to mass export all linked images in a Indesign document using this script, its from this thread

var myDoc = app.activeDocument,
apis = myDoc.allPageItems, pageItem, fileName;

while ( pageItem = apis.pop() ) {
  if ( !pageItem.graphics[0].isValid ){ continue;}

  fileName = File ( pageItem.graphics[0].itemLink.filePath ).name;
  fileName = fileName.replace( /\.[a-z]{2,4}$/i, '.jpg' );

  app.jpegExportPreferences.exportResolution = 2400;
  app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;

  //give it a unique name
  var myFile = new File ("C:/Users/RANFacistol-Mata/Desktop/Image Trial/"+ fileName);


  pageItem.exportFile(ExportFormat.JPG, myFile);
}

When i use this script, it export the linked images in the ratio how its placed in Indesign.

How its exported enter image description here

How it looks in Indesign enter image description here

Yet i want it to look like this, the original ratio of the image enter image description here

  • 1
    What about packaging your document and get the Links folder? – Vinny Feb 1 '18 at 13:35
  • Unless we're missing something in what you are asking, Vinny's idea of doing a simple package/collect for output would give you all your linked images. You could then use PS to automate the resizing. – GoofyMonkey Feb 1 '18 at 14:12
  • Yes i know that option, but title says mass export as individual jpgs. So i would like to know other options as well. The script is almost there yet exports the wrong ratio. – Rombout Versluijs Feb 1 '18 at 14:37
2

You need to export the graphic, not the object.
Add .graphics[0] before the exportFile function.

var myDoc = app.activeDocument,
    apis = myDoc.links.everyItem().getElements(),
    items, fileName;
var i = 0;
var MyPath = "C:/Users/xx/Desktop/test/"; // change your path here

alert("Script is running. Press OK and wait until done...");

while (items = apis.pop()) {
    items = items.parent.parent;
    if (!(items.hasOwnProperty("graphics"))) {
    continue;
    }
    i++;
    try {
        fileName = File(items.graphics[0].itemLink.filePath).name;
        fileName = i + "_" + fileName.replace(/\.[a-z]{2,4}$/i, '.jpg');
    } catch (e) {};

    app.jpegExportPreferences.exportResolution = 2400;
    app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;

    //give it a unique name
    var myFile = new File(MyPath + fileName);

    items.graphics[0].exportFile(ExportFormat.JPG, myFile);
}

alert("Done");

Edit: Or... package your links and use Photoshop batch function to save everything in JPG

  • Thanks @Vinny!!! you made my day, next time i should better check the settings. hahhaa you added 2400 at MAXIMUM took quite a while doing 123 images ;) – Rombout Versluijs Feb 2 '18 at 23:16
  • Well I just copied/pasted the script you were referring to. 2400 is a lot indeed, but you can easily change that in the script... – Vinny Feb 5 '18 at 9:41
  • Yes i know, 300 and MAXIMUM is good enough for me. Thanks again for the awesome adjustment! – Rombout Versluijs Feb 6 '18 at 15:59
  • How could i adjust this script so it export the placed image according to the frame. I know Indesign has the function export Selection. I cant figure out how to target that code? – Rombout Versluijs Nov 8 '18 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.