4 Replies Latest reply on Jan 17, 2011 3:15 AM by Kasyan Servetsky

    Get icc-profile from a image

    slusteg

      Is ist possible to get the ICC-profile of a image

       

      I try this with  a Adobe RGB 1998 with embeded profile:


      alert(app.activeDocument.selection[0].graphics[0] .profile);
      alert(app.activeDocument.selection[0].graphics[0] .space);

       

       

      But it only return  "Emdeded" for .profile and "RGB" for .space. But i want it to return adobe rgb 1998

       

       

      Is it possible?

        • 1. Re: Get icc-profile from a image
          Kasyan Servetsky Level 5

          As far as I know, you can't get profile of an image directly in InDesign, but you can get it via metadata:

          var link = app.selection[0].graphics[0].itemLink;
          var linkXmp = link.linkXmp;
          var profile = linkXmp.getProperty("http://ns.adobe.com/photoshop/1.0/", "ICCProfile");
          alert(profile);

           

          However not all images contain the nesessary metadata, especially some old files.

          You can check this by choosing Link File Info (in Links Panel menu) and going to Advanced section.

          12.01.png

          • 2. Re: Get icc-profile from a image
            slusteg Level 1

            Thank you, that's exactly what i wanted!

            • 3. Re: Get icc-profile from a image
              slusteg Level 1

              Why can't i read  the profile variable from PSD-documents file don't contain xmp profile variable when i look under link file info. But when i look link information i can read profile: adobe rgb

              Read from XMP script also don't work.

               

              But when i open i photoshop i can read it

               

               

              Bug?

               

              ps_vs_indesign_cs3.png

              • 4. Re: Get icc-profile from a image
                Kasyan Servetsky Level 5

                I can't think nothing better than temporarily open the link in Photoshop and get its embedded profile from there:

                #target indesign
                #targetengine "session"
                
                if (!BridgeTalk.isRunning("photoshop")) {
                     alert("Photoshop is not running.");
                }
                else {
                     var link = app.selection[0].graphics[0].itemLink;
                     CreateBridgeTalkMessage(link.filePath);
                }
                
                function CreateBridgeTalkMessage(filePath) {
                     var bt = new BridgeTalk();
                     bt.target = "photoshop";
                     var script = GetProfile.toString() + "\r";
                     script += "GetProfile(\""  + filePath + "\");";
                     bt.body = script;
                     // $.writeln(script);
                     bt.onResult = function(resObj) {
                          var result = resObj.body;
                          DisplayProfile(result);
                     }
                     bt.send(100);
                }
                
                function GetProfile(filePath) {
                     try {
                          app.displayDialogs = DialogModes.NO;
                          var psDoc = app.open(new File(filePath));
                          var prof = app.activeDocument.colorProfileName;
                          psDoc.close(SaveOptions.DONOTSAVECHANGES);
                          app.displayDialogs = DialogModes.ALL;
                          return prof;
                     }
                     catch(err) {
                          psDoc.close(SaveOptions.DONOTSAVECHANGES);
                          app.displayDialogs = DialogModes.ALL;
                     }
                }
                
                function DisplayProfile(result) {
                     alert( "Color profile is \"" + ((result == "undefined") ? "Not embedded" : result) + "\"");
                }
                
                1 person found this helpful