Skip to main content
Participating Frequently
January 11, 2011
Answered

Get icc-profile from a image

  • January 11, 2011
  • 1 reply
  • 2333 views

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?

This topic has been closed for replies.
Correct answer Kasyan Servetsky

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.

1 reply

Kasyan Servetsky
Kasyan ServetskyCorrect answer
Legend
January 12, 2011

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.

slustegAuthor
Participating Frequently
January 12, 2011

Thank you, that's exactly what i wanted!

Kasyan Servetsky
Legend
January 17, 2011

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?


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) + "\"");
}