• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to read Photoshop psd file metadata fields into python?

Contributor ,
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

1.1K

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 Expert ,
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

Votes

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
Contributor ,
Aug 19, 2021 Aug 19, 2021

Copy link to clipboard

Copied

Thank you, JJMack. That was very helpful.

Best wishes,

Rajnesh

Votes

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
LEGEND ,
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 😉

Votes

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
LEGEND ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

LATEST

Python XMP Toolkit

There are other projects available as well.

Votes

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