Skip to main content
Known Participant
May 30, 2008
Question

Bit Depth in XMP

  • May 30, 2008
  • 3 replies
  • 1180 views
Does anybody know of anyway of determining the bit depth of an image from it's
XMP? I know that raw files has a BitsPerSample property which I can deal with.
My problem is more with PSD files. I can't figure any way of determining whether
it's an 8 bit or 16 bit image strictly from the XMP data.

Anyone have any ideas?

-X
This topic has been closed for replies.

3 replies

Participating Frequently
November 30, 2008
Got it!

Good Luck.
______
My Si tes
dfranzen_camera_raw
Adobe Employee
Adobe Employee
June 27, 2008
There is a typo in my example. The part that gets the preview should look like this:

//force preview generation, if it hasn't happened yet
app.synchronousMode = true;
testThumb.core.preview.preview;
app.synchronousMode = false;

You can turn OFF synchronousMode after preview generation.

-David
_xbytor_Author
Known Participant
June 27, 2008
> You can turn OFF synchronousMode after preview generation.

Got it. Thanks.

--
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com
dfranzen_camera_raw
Adobe Employee
Adobe Employee
June 26, 2008
Hi X,

I think a more reliable approach to try would be get the bit depth discovered while Bridge looks at the actual image data during thumbnail and preview generation.

You can access this data from the Bridge cache through Thumbnail.core.quickMetadata.bitDepth -- but you will want to do it after a preview has been generated.

Try saving the following example script in a folder of PSD files and running it from ESTK:

#target bridge

function testBitDepth( testFile )
{
var testThumb = new Thumbnail( testFile );

var bitDepthBefore = testThumb.core.itemContent.bitDepth;

//force preview generation, if it hasn't happened yet
app.synchronousMode = true;
testThumb.core.preview.preview;
app.synchronousMode = true;

// retreive bit depth from the cache
var bitDepth = testThumb.core.quickMetadata.bitDepth;
$.writeln("Bit Depth for: " + testThumb.name + " is " + bitDepth + " (before: " + bitDepthBefore + ")" );
}

var curFolder = new File( $.fileName).parent;
var psdFiles = curFolder.getFiles("*.psd");

for( var f = 0; f < psdFiles.length; ++f )
{
var testFile = psdFiles;
try{
testBitDepth( testFile );
}catch( e ) {
$.writeln("Doh! Error testing " + testFile.name + " " + e );
}
}

This method should work for any file for which you can also see a bit depth reported in the "File Properties" section of the Bridge metadata panel.

Cheers,
David
_xbytor_Author
Known Participant
June 26, 2008
> This method should work for any file for which you can also see a bit depth reported in the "File Properties" section of the Bridge metadata panel.

Thanks for this. I guess I shoulda searched for 'bitDepth' in the docs :)
My code is using BitsPerSample from XMP at the moment, but that's nowhere near
universal. I'll see if I can make this fit.

-X
--
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com