Skip to main content
tpk1982
Legend
December 29, 2015
Answered

Embed or None

  • December 29, 2015
  • 2 replies
  • 917 views

Hi,

I am trying to find the ICC profile for all links in the document. The below is the tried coding. But it not working. It show error. I thought it may be because of eps file present but not sure.

for (img=0; img<app.activeDocument.allGraphics.length; img++) {

alert(app.activeDocument.allGraphics[img].profile)}

The below screenshot illustrates the error details.

I need to find the image names for "None" ICC profile. Is it possible?

Advance thanks,

Karthi

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

Thanks Kasyan. I tested one psd file and got same "No profile" alert

Please download the PSD from the below link:

Dropbox - example fonts and symbols.psd


You can't get profile name because it's not there:

Another approach is temporarily open it in Photoshop (via BridgeTalk) and read the profile like this:

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

}

But it says that it's not embeded.

So it's unavailable even directly in Photoshop. However this script was written for an earlier version and something probably has changed since.

There's another property in Photoshop -- colorProfileType -- which can be one of the following:

When I run this script in PS with your file open, I get None:

main();

function main() {

    var doc = app.activeDocument;

    var colorProfileType = doc.colorProfileType;

}

2 replies

Kasyan Servetsky
Legend
December 30, 2015

For raster images I suggest reading the profile name from metadata like so:

main();

function main() {

    var link, metaData, profile,

    doc = app.activeDocument;

   

    for (var i = 0; i < doc.links.length; i++) {

        link = doc.links;

        metaData = link.linkXmp;

        profile = metaData.getProperty("http://ns.adobe.com/photoshop/1.0/", "photoshop:ICCProfile");

        $.writeln(link.name + " - " + ((profile == "") ? "No profile" : profile));

    }

}

Here is an InDesign file I used for testing.

With vector files -- EPS, AI -- things are more complicated: I applied Edit > Assign Profile command in Illustrator. But it seems that the profile is not kept with the file: in Bridge it's displayed as untagged and I couldn't find it in metadata -- File Info > Advanced tab.

tpk1982
tpk1982Author
Legend
December 30, 2015

Hi Kasyan,

If it is alert "No Profile" then we can assume it is not embedded?

Kasyan Servetsky
Legend
December 30, 2015

If  property is empty string, no profile is embedded. But this doesn't work with vector images.

tpk1982
tpk1982Author
Legend
December 30, 2015

Hi All,

Any suggestions please.

Peter Kahrel
Community Expert
Community Expert
December 30, 2015

The graphics object doesn't have a property 'profile', as your error message indicates, and as you'll discover when, just to make sure because you never know, you check the object model.

Peter

tpk1982
tpk1982Author
Legend
December 30, 2015

Hi Peter,

Yeah but it is showing correct alert for some graphics. That is strange. So cit confused where it stopped