Export page with linked image name

Learn / Forums / General InDesign Topics / Export page with linked image name

Viewing 5 reply threads
  • Author
    Posts
    • #1225368
      Brent Wouda
      Participant

      Hello,
      I have an Indesign file that has one image on every page (I used a script “image to csv”).
      I would like to export each page as an png.

      Now here is the thing: I want to have each page be named after the image that is linked on the page.

      backgroud information
      I know some people use photoshop to make a batch to resize images. Thing is that from time to time I need to overrule and adjust the landscape / portrait images into square images. Therefore I use indesign to make an image fit, resize etc I even have a set of pre-made arrows and lines to add some extra here and there on top of the image. That is why I choose indesign, to run the csv, data merge and the next automation is save each page as a new image that has the original image name…

      Hope someone can provide a script or different automation work around to save me loads of time .

      Thanks in advance

      Brent

      ps. am using indesign cc 2020

    • #14323189
      Jeremy Howard
      Participant

      Give this a shot:

      var aDoc = app.activeDocument;
      var docPages = aDoc.pages;

      for(p=0;p<docPages.length;p++){

      var myPageItems = docPages[p].allPageItems
      var myPageName = docPages[p].name;

      for(i=0;i<myPageItems.length;i++){

      //set selection as variable
      var thisItem = myPageItems[i];
      if(thisItem instanceof Rectangle || thisItem instanceof Polygon || thisItem instanceof Oval){

      //get image within the frame
      var myLinkedItem = thisItem.pageItems[0];
      //get name of the linked image
      var myLinkName = myLinkedItem.itemLink.name;

      //strip extension from linked image name
      var myLinkName = myLinkName.split(“.”)[0];

      app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.maximum; // low medium high maximum
      app.jpegExportPreferences.exportResolution = 300;
      app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
      app.jpegExportPreferences.pageString = myPageName;

      //Set Name of exported pdf to match the name of the linked image
      var myFile = File(“/Users/admin/Desktop/” + myLinkName + “.jpg”);

      //export the pdf
      aDoc.exportFile(ExportFormat.JPG, myFile, false);
      }
      }
      }

    • #14323188
      Brent Wouda
      Participant

      Thanks for you reply.
      I get a javascript error.

      https://paste.pics/7V33S

      Is it possible to fix it (mistake nr 8 on line 21)
      And is it possible to export a png (72 dpi) /

      Thanks in advance

    • #14323187
      Brent Wouda
      Participant

      Thanks for you reply.
      I get a javascript error.

      Is it possible to fix it (mistake nr 8 on line 21)
      And is it possible to export a png (72 dpi) /

      Thanks in advance

    • #14323185
      Vinny –
      Member

      This is a WordPress thing.
      Try changing the pasted quotes into straight quotes.
      Also, change them on the line defining “var myFile = …” (that you also might have to change, according to your OS and/or your desired destination)

    • #14323183
      Brent Wouda
      Participant

      Thanks
      Solved the quotes issue.

      But…
      It seems it actually looks for the original image on the desktop or the file destination i provide.
      Then it cannot find it.
      https://paste.pics/7V9FS

      the original files are in a google drive. the export can go wherever I want but so far no export.
      By the way: I changed into: var myFile = File(“/C:/scriptindesign/” + myLinkName + “.jpg”);

Viewing 5 reply threads
  • You must be logged in to reply to this topic.
>