How to read Photoshop psd file metadata fields into python?
Copy link to clipboard
Copied
Hello,
I need to read and modify a Photoshop psd file's metadata fields such as:
- Description,
- Document Title and
- Keywords
into Python. Could you point me to Resources/ Examples of how I can do this?
Thank You, in advance, for your help.
Rajnesh
Explore related tutorials & articles
Copy link to clipboard
Copied
Use the bridge or Photoshop menu File>File Info. Adobe Scriptinf supporte Action Mabager vode in JavaScript and I beluevet there may be some extenstin that can use Python scripting.
JavaScript
xml = app.activeDocument.xmpMetadata.rawData;
logInfo( xml);
function logInfo(Txt){
try {
var file = new File(Folder.desktop + "/temp1.txt");
file.open("w", "TEXT", "????");
//alert(file.encoding);
file.encoding = "UTF8";
file.seek(0,2);
$.os.search(/windows/i) != -1 ? file.lineFeed = 'windows' : file.lineFeed = 'macintosh';
file.writeln(Txt);
if (file.error) alert(file.error);
file.close();
file.execute();
}
catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }
};
You can access meta data objects like info with javascript code like this. that check Info instructions for garbage and add garbage to instruction if it not in instructions I do to to avoid a problem Adobe introduced in CC 2015.5
if (app.activeDocument.info.instructions.indexOf("Garbage") == -1 ) app.activeDocument.info.instructions = app.activeDocument.info.instructions + "Garbage";
Copy link to clipboard
Copied
Thank you, JJMack. That was very helpful.
Best wishes,
Rajnesh
Copy link to clipboard
Copied
Post how you do it in Python after you find how to do it 😉
Copy link to clipboard
Copied
There are other projects available as well.

