10 Replies Latest reply on Sep 15, 2013 4:47 AM by Harbs.

    Find dpi Photoshop eps

    BEGINNER_X Level 3

      Hi All,

       

      Is it possible to find dpi for the photoshop eps?

       

      The below code is working fine for the extension of ".tif" only.

       

      var myDoc = app.activeDocument;
      var myGraphics = app.activeDocument.allGraphics;
        
      for (var i = 0; i < myGraphics.length; i++) {
        if (myGraphics[i].effectivePpi[0] < 300 || myGraphics[i].effectivePpi[1] < 300) {
            var myPPI = myGraphics[i].effectivePpi[0] + " dpi\r";
            var myLowResImage = myGraphics[i].itemLink.name;
            alert("myLowResImage: " + myLowResImage + "\r" + "myPPI: " + myPPI);
         };
      };  
      

       

      Please anyone give solution for my request.

       

      Regards

      Beginner_X

        • 1. Re: Find dpi Photoshop eps
          Laubender Adobe Community Professional & MVP

          @Beginner_X – the InDesign preflight feature is able to catch effective PPI from eps files.
          I have no code for you, but can remember that thiese issues were already discussed in this forum.

           

          On the other hand you could use bridgetalk scripting to open an eps in PhotoShop (as long it is an PhotoShop eps) from an InDesign ExtendScript to read out the values and calculate effective ppi from its width and height in InDesign.

           

          There should be a couple of examples discussed here around…

           

          Uwe

          • 2. Re: Find dpi Photoshop eps
            Trevorׅ Adobe Community Professional

            I thought eps was a vector format that by definition doesn't have resolution.

             

            Either way for and example of using bridgetalk to get resolution from photoshop see

            #9 http://forums.adobe.com/message/4542274#4542274

            • 3. Re: Find dpi Photoshop eps
              Trevorׅ Adobe Community Professional

              See #18 http://forums.adobe.com/message/3879802#3879802

              Uwes over there in #19 (and other places)

              • 4. Re: Find dpi Photoshop eps
                Larry G. Schneider Adobe Community Professional & MVP

                EPS (Encapsulated PostScript) is a container which can have all manner of raster as well as vector items within it as long as it can be described in the PostScript printer language.

                • 5. Re: Find dpi Photoshop eps
                  Trevorׅ Adobe Community Professional

                  Yep,

                   

                  Seeing as it is a container which can contain vector and raster images and that the raster images can all be of differing resolutions , do you think it would be possible to get the resolution of the individual images?

                   

                  I suspect that there must be in the eps a source of raster images, so if one could somehow extract the list and get hold of the images one could send them off to Photoshop or even InDesign to get the resolution.

                   

                  No interest in putting good time into that for free

                   

                  Good luck X

                  • 6. Re: Find dpi Photoshop eps
                    Vamitul Level 4

                    here is some documentattion about the eps format. Not much, but with some knowlege of postscript language, not impossible to implement:

                    http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf

                     

                    edit:

                    The Postscript language reference:

                    http://partners.adobe.com/public/developer/en/ps/PLRM.pdf

                     

                    most interesting for this problem, is chapter 4.10: Images

                    • 7. Re: Find dpi Photoshop eps
                      BEGINNER_X Level 3

                      Hi All,

                       

                      Thanks all for your extreme advice and support...

                       

                      If it should possible through script means, then can anyone help me to provide the script to find the photoshop eps dpi.

                       

                      Thanks in advance

                      Beginner_X

                      • 8. Re: Find dpi Photoshop eps
                        BEGINNER_X Level 3

                        Hi All,

                         

                        Any update or script for the above request.

                         

                        Thanks

                        Beginner_X

                        • 9. Re: Find dpi Photoshop eps
                          bastieneichenberger Level 1

                          Hi,

                           

                          I find a way to do this for you … Its quite complecated but I comment my code.

                          I think its easier to do this with photoshop so my script use indesign and photoshop.

                          Put some image in a document: Tiff, EPS (raster), EPS (vector) …

                          Open Photoshop -> run this script.

                           

                          I would appreciate a feed-back.

                          Bye

                           

                           

                          #target indesign
                          
                          
                          var my_doc = app.activeDocument;
                          var array_links_item = my_doc.links;
                          
                          
                          // get all links
                          try{
                              for(var i=0; i < array_links_item.length; i++){
                                  display_resolution_eps (array_links_item[i]);
                              }
                          }
                          catch(ex){
                              alert(ex.message);
                          }
                          
                          
                          
                          
                          
                          
                          /** function who return the resolution
                           *    if the link is EPS -> open in photoshop to know the resolution
                           *    return the resolution
                          **/
                          function display_resolution_eps(link_item){
                              var image = link_item.parent;
                              var file_path = link_item.filePath;
                              var resolution = null;
                              
                              if(link_item.linkType == "EPS"){
                                  var eps_img = new File(link_item.filePath);
                                  if(is_raster_eps (eps_img) ){
                                     // eps file with raster
                                     // open in photoshop (It would be possible to read the EPS file and catch the boundaryBox but its more complicated
                                     resolution = get_resolution_bridge_talk({
                                         file_path : encodeURI(file_path)
                                     });
                                  }
                              }
                              else{
                                  resolution = image.actualPpi[0];
                              }
                              alert(resolution);
                              return resolution;
                          }
                          
                          
                          
                          
                          // function to check if a file type EPS is a raster file
                          // open the file and read the postScript, check if the software creator is Adobe Photoshop
                          function is_raster_eps(file){
                             var eps_file = file;
                             eps_file.open('r');
                             var str =eps_file.read();
                             eps_file.close();
                             var res = str.match('Adobe Photoshop');
                             if(res != null){
                                  res = true;
                             }
                             else{
                                  res = false;
                             }
                             return (res);
                          }
                          
                          
                          // this function open a bridge talk and exectute the function get_resolution_ps in photoshop
                          function get_resolution_bridge_talk(obj){
                              var error = null;
                              var result = null;
                              var bt = new BridgeTalk();
                               bt.target = "photoshop";
                               bt.body = get_resolution_ps.toSource()+"("+obj.toSource()+");";
                               bt.onError = function(ex){
                                  error = ex.body
                               }
                               bt.onResult = function(obj){
                                  result = obj.body;
                               }
                               bt.send(100);
                               if(error != null){
                                  throw new Error(error);
                               }
                              return result;
                          }
                          
                          
                          function get_resolution_ps(serializedObject){
                              app.displayDialogs = DialogModes.NO;
                              app.preferences.rulerUnits = Units.MM;
                              
                              var obj = eval(serializedObject);
                              var file_path = decodeURI(obj.file_path);
                              var img_file = new File(file_path);
                              var ps_doc = app.open(img_file);
                              
                              var resolution = ps_doc.resolution;
                              ps_doc.close();
                              app.displayDialogs = DialogModes.ALL;
                              return resolution;
                          }
                          
                          
                          • 10. Re: Find dpi Photoshop eps
                            Harbs. Level 6

                            This will not get the exact resolution, but you can use preflight to find out if an eps is higher than a predefined resolution.