Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to read Photoshop psd file metadata fields into python?

Participant ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

Hello,

 

I need to read and modify a Photoshop psd file's metadata fields such as: 

  1. Description, 
  2. Document Title and 
  3. Keywords 

into Python. Could you point me to Resources/ Examples of how I can do this?

 

Thank You, in advance, for your help.

Rajnesh

TOPICS
Actions and scripting, macOS

Views

73

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 18, 2021 Aug 18, 2021

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); }
};   

 

 

 

image.png

 

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";

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 19, 2021 Aug 19, 2021

Copy link to clipboard

Copied

Thank you, JJMack. That was very helpful.

Best wishes,

Rajnesh

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

Post how you do it in Python after you find how to do it 😉

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

LATEST

Python XMP Toolkit

There are other projects available as well.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines