Photoshop: Access placed file (per layer) metadata

  • 2
  • Idea
  • Updated 2 years ago
  • (Edited)
Okay, I have an idea I would like to see accomplished in Photoshop, any solutions would be welcomed and if there aren't any currently someone that want to create it would be welcome to. When you create a layout, for any project, and you are importing and placing files in the project it would be nice to have a type of "metadata" file being kept about what files are being placed and their source.

So for example, I am creating a montage of different files for a digital painting, when I place picture A in to the file, it would be nice if I could go up to the menu and see that file name: Picture A; source: stockphotos was placed in the file.

This solves two things, if I want to give credit where credit is due for images I could, and as an designer and photographer, if an image is created with liscensed images that were lifted, then the file would have that information attached to it as well! Pirating would be less prevalent. Not sure what you could do about copy and paste but it would cut down on some of it and would be so helpful for others.

Clear as mud? Need defined? If there is something out there that adds this functionality to Photoshop please let me know, if not....please create it!
Photo of Schwabby

Schwabby

  • 3 Posts
  • 0 Reply Likes

Posted 7 years ago

  • 2
Photo of Brett N

Brett N, Official Rep

  • 2258 Posts
  • 114 Reply Likes
Have you tried Placing these photos as Smart Objects? A Smart Object is an embedded file. So if you've brought in a number of images to make a montage or collage, you can simply double-click on the layer thumbnail, this will open the original file, where you can view it's metadata by going to File > File Info.

Otherwise, there currently is no method of creating layer or pixel specific metadata.

Maybe not a perfect solution (the information isn't available directly from the menus) but it should suffice.
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 13996 Posts
  • 1709 Reply Likes
Actually, there is a way to apply and retrieve per layer metadata using the scripting API. It's still a pretty geeky thing. I agree, for average users using Smart Object layers is the most straight forward way to retain access to the original file and it's metadata.

http://www.adobe.com/devnet/photoshop...
Photo of Schwabby

Schwabby

  • 3 Posts
  • 0 Reply Likes
Could you define it a bit more? I am a geeky person so, I can usually figure things out but there are about a bazillion choices, and while some of them are quite obvious what not to use others are not, and I am not sure how to use the Scripting API. Thank you!
Photo of Ken

Ken

  • 146 Posts
  • 34 Reply Likes
Brett,
Is that feature only available in the "big" PhotoShop? When I double-click on a placed Smart Object's thumbnail in PSE10, all I get is the Layer Properties dialog.

Ken
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 13996 Posts
  • 1699 Reply Likes
That's correct. You can only access Smart Object contents in Photoshop CS and not with Elements.
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 14049 Posts
  • 1735 Reply Likes
Schwabby,

Not sure how geeky you want to get, but here goes. Here's some sample code. This will only work on floating layers (not Background Layers).


// Load AdobeXMPScript library
loadXMPScript();

// read the layers "Description" metadata

try{
// Get a raw dump of the document's XMP Metadata
// xmpStr =app.activeDocument.xmpMetadata.rawData;
// Get a raw dump of the layer's XMP Metadata
xmpStr =app.activeDocument.activeLayer.xmpMetadata.rawData;
} catch(e){
var noLayerMetadata = true;
}

if (noLayerMetadata == true){
// Create a new empty XMP Object
xmpObject = new XMPMeta();
}else{
// Create an new XMP Object from the raw dump string
xmpObject = new XMPMeta(xmpStr);
}

// Get the array of items in the XMP Descripting field
var tmpCount = xmpObject.countArrayItems(XMPConst.NS_DC, "description");

// How many items are in the array?
alert("DC object of array description has " + tmpCount);

if (tmpCount == 0){ // there is no current layer metadata for description
// Need to "append" the desciption...
xmpObject.appendArrayItem(XMPConst.NS_DC, "description", null , XMPConst.PROP_IS_ARRAY, XMPConst.ARRAY_IS_ORDERED);
// Then we can "insert" a string into the description tag
xmpObject.insertArrayItem(XMPConst.NS_DC, "description", 1, "This is a NEW Description");
}else{ // there is already layer metadata for description
// Therefore, we can just 'set" the string to something else.
xmpObject.setArrayItem(XMPConst.NS_DC, "description", 1, "This is the CHANGED description");
}

// Finally, we need to serialize the changes
app.activeDocument.activeLayer.xmpMetadata.rawData = xmpObject.serialize();

// Unload AdobeXMPScript library
unloadXMPScript();

/////////////////////////
// FUNCTIONS
/////////////////////////

// =================================================================
/**
* XMPLib Message structure - to use this: var myvar = new XMPLibMsg();
* @param {String} String message that you want to store
* @param {Integer} line number, if exist from error code
* @param {Boolean} true if error occurred, false if successful
* @return the structure back
*/
function XMPLibMsg (inMessage, inLine, inError)
{
this.message = inMessage;
this.line = inLine;
this.error = inError;
}

// =================================================================
/**
* Load AdobeXMPScript library
* @return a XMPLibMsg object with status. message contains the message, line is the error line (if exist), error set to true if error occurred
*/
function loadXMPScript()
{
var results = new XMPLibMsg("XMPScript Library already loaded", 0, false);

if (!ExternalObject.AdobeXMPScript)
{
try
{
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
results.message = "XMPScript Library loaded";
}
catch (e)
{
results.message = "ERROR Loading AdobeXMPScript: " + e;
results.line = e.line;
results.error = true;
}
}

return results;
}

// =================================================================
/**
* unload AdobeXMPScript library
* @return a XMPLibMsg object with status. message contains the message, line is the error line (if exist), error set to true if error occurred
*/
function unloadXMPScript()
{
var results = new XMPLibMsg("XMPScript Library not loaded", 0, false);

if( ExternalObject.AdobeXMPScript )
{
try
{
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
results.message = "XMPScript Library successfully unloaded";
}
catch (e)
{
results.message = "ERROR unloading AdobeXMPScript: " + e;
results.line = e.line;
results.error = true;
}
}

return results;
}

// =================================================================
/**
* Given 2 memory snapshot, it reports the memory snapshot
* @param {Long} The first free memory value
* @param {Long} The second free memory value
* @return {String} Formatted info on memory snapshot
*/

function reportMemoryStat(mBefore, mAfter)
{
var localTempMem;
var results;

if (mBefore > mAfter)
localTempMem = mBefore - mAfter;
else
localTempMem = mAfter - mBefore;
results = "Free memory before: " + mBefore + "\n";
results += "Free memory after: " + mAfter + "\n";
results += "Difference: " + localTempMem + "\n";

return results;
}
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 14049 Posts
  • 1735 Reply Likes
The above example sets the layer metadata. Here's how to retrieve it:


// Load AdobeXMPScript library
loadXMPScript();

// read the layers "Description" metadata

try{
// Get a raw dump of the document's XMP Metadata
//xmpStr =app.activeDocument.xmpMetadata.rawData;
// Get a raw dump of the layer's XMP Metadata
xmpStr =app.activeDocument.activeLayer.xmpMetadata.rawData;
} catch(e){
alert("No Layer Metadata");
}

// Create an XMP Object from the raw dump string
xmpObject = new XMPMeta(xmpStr);

// Get the array of items in the XMP Descripting field
var tmpCount = xmpObject.countArrayItems(XMPConst.NS_DC, "description");

// How many items are in the array?
alert("DC object of array description has " + tmpCount);

// Now step through each of the array items and alert their value
if (tmpCount > 0){
for (i=1; i <= tmpCount; i++) {
tempStr = xmpObject.getArrayItem(XMPConst.NS_DC, "description", i);
alert("Description " + i + " = " + tempStr);
}
}

// Unload AdobeXMPScript library
unloadXMPScript();

/////////////////////////
// FUNCTIONS
/////////////////////////

// =================================================================
/**
* XMPLib Message structure - to use this: var myvar = new XMPLibMsg();
* @param {String} String message that you want to store
* @param {Integer} line number, if exist from error code
* @param {Boolean} true if error occurred, false if successful
* @return the structure back
*/
function XMPLibMsg (inMessage, inLine, inError)
{
this.message = inMessage;
this.line = inLine;
this.error = inError;
}

// =================================================================
/**
* Load AdobeXMPScript library
* @return a XMPLibMsg object with status. message contains the message, line is the error line (if exist), error set to true if error occurred
*/
function loadXMPScript()
{
var results = new XMPLibMsg("XMPScript Library already loaded", 0, false);

if (!ExternalObject.AdobeXMPScript)
{
try
{
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
results.message = "XMPScript Library loaded";
}
catch (e)
{
results.message = "ERROR Loading AdobeXMPScript: " + e;
results.line = e.line;
results.error = true;
}
}

return results;
}

// =================================================================
/**
* unload AdobeXMPScript library
* @return a XMPLibMsg object with status. message contains the message, line is the error line (if exist), error set to true if error occurred
*/
function unloadXMPScript()
{
var results = new XMPLibMsg("XMPScript Library not loaded", 0, false);

if( ExternalObject.AdobeXMPScript )
{
try
{
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
results.message = "XMPScript Library successfully unloaded";
}
catch (e)
{
results.message = "ERROR unloading AdobeXMPScript: " + e;
results.line = e.line;
results.error = true;
}
}

return results;
}

// =================================================================
/**
* Given 2 memory snapshot, it reports the memory snapshot
* @param {Long} The first free memory value
* @param {Long} The second free memory value
* @return {String} Formatted info on memory snapshot
*/

function reportMemoryStat(mBefore, mAfter)
{
var localTempMem;
var results;

if (mBefore > mAfter)
localTempMem = mBefore - mAfter;
else
localTempMem = mAfter - mBefore;
results = "Free memory before: " + mBefore + "\n";
results += "Free memory after: " + mAfter + "\n";
results += "Difference: " + localTempMem + "\n";

return results;
}
Photo of venice raj

venice raj

  • 1 Post
  • 0 Reply Likes
This reply was created from a merged topic originally titled NewLayer Property.

Dear Sir/Madam
 is't possible to add Layer property in hidden or direct like Tag (in vb programming language)
because if i insert a file into a document as a layer i want to store it's location or any other details into a layer (not group or smart object) i need a property like Name
 
i am an album designer i will add 10 images into a single document so that if the tag is possible then i will add the filename or any other details in single layer it will helpful to retrieve with SCRIPT

i could change Layer Name = Fiile path but this is really weird

if Tag is hidden/direct then really very very helpful


Thanks 
Venice Raj
VRDigital
Licensed Adobe Photoshop CS6
Madurai.