Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Javascript select image from specific layer

Return to Member Forum

  • Author
    Posts
    • #14338746

      Hi everyone,

      I’m having trouble with a script that I’ve adapted to suit my need.
      Now I’m would like to apply that script to a specific layer, but don’t know where to start.

      Here’s the script:

      //Exportations des images en JPG
      var myDoc = app.activeDocument,
      apis = myDoc.links.everyItem().getElements(),
      items, fileName;
      var i = 0;
      var MyPath = Folder.selectDialog(“Enregistrer les images en JPEG – 100 dpi – Qualité Compression : High”);

      alert(“Le script travaille, merci d’attendre un peu…”);
      //alert(MyPath);

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

      app.jpegExportPreferences.exportResolution = 200;
      app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;

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

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

      }
      alert(“Le script a terminé son travail. Vous pouvez exporter vos images dans Virtual Paper. Merci!VirtualPaper JPEG Exporter 2.1 (03/2021) pour InDesign CC© &CO • 2021”);

      If someone could help me out.

      Thanks Patrick

    • #14338891


      if ( items.itemLayer.name == “specific layer name” ) {
      try {
      fileName = File(items.graphics[0].itemLink.filePath).name;
      fileName = fileName.replace(/\.[a-z]{2,4}$/i, “.jpg”);
      } catch (e) {};
      app.jpegExportPreferences.exportResolution = 200;
      app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH;
      //give it a unique name
      var myFile = new File( myPath + “/” + fileName );
      items.graphics[0].exportFile( ExportFormat.JPG, myFile );
      }

      (^/) The Jedi

Viewing 1 reply thread
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads