Skip to main content
gregreser
Legend
February 8, 2013
Answered

Can't export ColorMode or ICCProfile values

  • February 8, 2013
  • 1 reply
  • 1970 views

I have had good luck exporting file metadata with JavaSCript so far, but there are two properties that keep returning "undefined"; photoshop:ColorMode and photoshop:ICCProfile.

Other photoshop properties export just fine, but nothing I've tried works for these two. I thought it might be because they are "internal" properties, but I am able to export other "internal" properties, such as exif xResolution.

var cm= xmpData.getProperty (XMPConst.NS_PHOTOSHOP, "ColorMode");

if (cm !== undefined){

dataExport.write ('\t' + cm);

}

else{

dataExport.write ('\t');

var icc= xmpData.getProperty (XMPConst.NS_PHOTOSHOP, "ICCProfile");

if (icc !== undefined){

dataExport.write ('\t' + icc);

}

else{

dataExport.write ('\t');

}

Thanks,

Greg Reser

This topic has been closed for replies.
Correct answer Paul Riggott

Hi Greg please try these...

var cm= xmpData.getProperty (XMPConst.NS_PHOTOSHOP, "ColorMode").toString();

var icc= xmpData.getProperty (XMPConst.NS_PHOTOSHOP, "ICCProfile").toString();

1 reply

Paul Riggott
Paul RiggottCorrect answer
Inspiring
February 8, 2013

Hi Greg please try these...

var cm= xmpData.getProperty (XMPConst.NS_PHOTOSHOP, "ColorMode").toString();

var icc= xmpData.getProperty (XMPConst.NS_PHOTOSHOP, "ICCProfile").toString();

gregreser
gregreserAuthor
Legend
February 11, 2013

Thanks Paul, that does help but it turned out that my problem was a corrupted image. I was still getting no results with toString() so I started testing other images. I was able to export ColorMode and ICCProfile eother with or without toString() leading me to believe that Bridge can, in some cases, figure out if the data is a number or a string. This is not true if you are going to perform an action on the data, like split or Math. In those cases you have to make sure the data is of the correct type.

This post might really be about the oddities of corrupted files. The file in question displays data in the file info panel and the Bridge metadata palette display all the data correctly and the raw XMP file looks normal as far as I can tell.

Thanks for the help,

Greg

Paul Riggott
Inspiring
February 11, 2013

That is interesting, I have just done a few test with CS5 and CS6 both of which required .toString() or Number();

but there was no problem extracting the fields with ...

var thumb = app.document.selections[0];
var md = thumb.synchronousMetadata;
var cm = md.read("http://ns.adobe.com/photoshop/1.0/",  "photoshop:ColorMode");
var icc = md.read("http://ns.adobe.com/photoshop/1.0/",  "photoshop:ICCProfile");

alert(cm);
alert(icc);