2 Replies Latest reply on Nov 7, 2013 1:09 AM by beh_gras_beh

    JPG resolution and quality

    beh_gras_beh Level 1

      Dear Indesign scripters,

       

      I'm having a very old script what I made for CS2 and still using for CS5.

      Now I'm having trouble to give it the option to choose the resolution in a dialog box.

      Know I'm typing the resolution manually in the script but I’m wondering if there is a way to do it with a dialog box.

       

      
      var myDoc = app.documents[0];
      app.scriptPreferences.version = "6.0"
      
      if(app.documents.length != 0){   
           var myFolder = Folder.selectDialog ("Choose a Folder");   
           if(myFolder != null){   
                myExportPages(myFolder);   
           }   
      }   
      else{   
           alert("Please open a document and try again.");   
      }   
      function myExportPages(myFolder){   
           var myDocument = app.activeDocument;   
           var myDocumentName = myDocument.name;   
      
      
      //________________________________________________________________
      
      app.jpegExportPreferences.resolution = 150;
      app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;
      
      // JPEGOptionsQuality.LOW, JPEGOptionsQuality.MEDIUM, JPEGOptionsQuality.HIGH, JPEGOptionsQuality.MAXIMUM
      //________________________________________________________________
      
      
      
      
      app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
      app.scriptPreferences.version = "7.0"
      app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.RGB;
      app.scriptPreferences.version = "6.0"
      app.activeDocument.sections.everyItem().includeSectionPrefix = false; 
      p = app.activeDocument.pages.everyItem().getElements();
      for (i = 0; i < p.length; i++)
      
      
      { 
      f = File (myFolder + "/" + p[i].textFrames.item ('labelcode').contents + ".jpg");
      app.jpegExportPreferences.pageString = p[i].name; 
      app.activeDocument.exportFile (ExportFormat.jpg, f );
      
                }   
           }   
      alert('Done!');
      

       

      Already thanks for the help.

      Greetings.

        • 1. Re: JPG resolution and quality
          Sajeev Sridharan Level 4

          Try the below code,

           

          If you want to create UI, Peter Kahrel documentation will be very useful for you.

           

          http://www.kahrel.plus.com/indesign/scriptui.html

           

           

          var myDoc = app.documents[0];

          app.scriptPreferences.version = "6.0"

           

          if(app.documents.length != 0){  

               var myFolder = Folder.selectDialog ("Choose a Folder");  

               if(myFolder != null){  

                    myExportPages(myFolder);  

               }  

          }  

          else{  

               alert("Please open a document and try again.");  

          }  

          function myExportPages(myFolder){  

               var myDocument = app.activeDocument;  

               var myDocumentName = myDocument.name;  

           

           

           

          //________________________________________________________________

           

           

          var w = new Window ("dialog", "Resolution Dialog");

          var e = w.add ("edittext", undefined, "type your resolution here");

          w.layout.layout();

          e.active = true;

          w.add ("button", undefined, "OK");

          w.show();

           

           

           

          //________________________________________________________________

           

          app.jpegExportPreferences.resolution = Number(e.text);

          app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;

           

          // JPEGOptionsQuality.LOW, JPEGOptionsQuality.MEDIUM, JPEGOptionsQuality.HIGH, JPEGOptionsQuality.MAXIMUM

          //________________________________________________________________

           

          app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;

          app.scriptPreferences.version = "7.0"

          app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.RGB;

          app.scriptPreferences.version = "6.0"

          app.activeDocument.sections.everyItem().includeSectionPrefix = false;

          p = app.activeDocument.pages.everyItem().getElements();

          for (i = 0; i < p.length; i++)

           

          {

          f = File (myFolder + "/" + p[i].textFrames.item ('labelcode').contents + ".jpg");

          app.jpegExportPreferences.pageString = p[i].name;

          app.activeDocument.exportFile (ExportFormat.jpg, f );

           

                    }  

               }  

          alert('Done!');

           

           

           

          Vandy

          • 2. Re: JPG resolution and quality
            beh_gras_beh Level 1

            That works perfectly, thank you very much!

             

            And thanks for the tip, i'ts rolling out of the printer as we speek!

             

             

            Greetings