Skip to main content
Inspiring
February 15, 2023
Question

Is there an equivalent of deleteProperty(XMPConst.NS_DC, "description”) for EXIF:ImageDescription an

  • February 15, 2023
  • 2 replies
  • 2640 views

I want to remove the tags/descriptions below from TIF, PSD and PSB images:

[EXIF:IFD0] .........ImageDescription  

[XMP:XMP-dc].....Description

[IPTC]....................Caption-Abstract

 

I can do this with ExifTool with this code:

 

exiftool -m -overwrite_original_in_place -EXIF:ImageDescription= -XMP-dc:Description= -IPTC:Caption-Abstract= 

 

Can anyone help me do this with a script on MacOS without using ExifTool? 

 

I don’t have much coding experience, but I found the code below as a starting point without using Photoshop (though I don’t need to write anything to it as this code does… I’d prefer just to delete or wipe the tags/content so they don’t show up).

 

Sample Code without Photoshop/Bridge:

 

Code: Select allvar f = File("/c/captures/a.jpg");
setDescription(f,"My new description");

function setDescription( file, descStr ){
if ( !ExternalObject.AdobeXMPScript ) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
        var xmpf = new XMPFile( File(file).fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE );
        var xmp = xmpf.getXMP();
        xmp.deleteProperty(XMPConst.NS_DC, "description");
        xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", descStr );
      if (xmpf.canPutXMP( xmp )) {
         xmpf.putXMP( xmp );
      }
      xmpf.closeFile( XMPConst.CLOSE_UPDATE_SAFELY );
}

 

 

And here is some alternate partial code from within Photoshop when Opening a Document:

 

function removeDescription() {
    whatApp = String(app.name);
    if(whatApp.search("Photoshop") > 0)  
          if(!documents.length) {
        alert("There are no open documents. Please open a file to run this script.")
        return;
        }
        if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
        var xmp = new XMPMeta( activeDocument.xmpMetadata.rawData);
             xmp.deleteProperty(XMPConst.NS_DC, "description");
            app.activeDocument.xmpMetadata.rawData = xmp.serialize();
         }
}
removeDescription();

 

 

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
February 16, 2023

What if a script removed "all" metadata? Is that too excessive?

Chris.SAuthor
Inspiring
February 17, 2023

Odd... I could swear I responded to your questions earlier @Stephen Marsh.

 

First, regarding Document Ancestors, yes, I was already able to get that to work fine. I had removed that code since it didn't apply to this particular question, but I am able to get rid of that with the lines of code below. However, I appreciate the additional resources on that.

 ...
var xmp = new XMPMeta( activeDocument.xmpMetadata.rawData);
            xmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "DocumentAncestors");
...

Second, regarding removal of all metadata, yes, that would be too excessive. I actually use the other metadata in combination with ExifTool and Filemaker locally to QC incoming files to ensure they were built to the proper spec (profiles, resolution, size, etc.) based on the end use case for the image... much faster and more accurate than opening lots of 2-10GB files.

Stephen Marsh
Community Expert
Community Expert
February 16, 2023

With ExifTool being the gold standard for metadata, you may be hard-pressed to do everything in Adobe software.

 

Put another way, if you can do it in ExifTool, WHY look elsewhere? Where/how in the workflow do you wish to do this?

 

In Adobe software, it is often easier to remove metadata in a broad group, such as "ALL" XMP metadata, rather than trying to do so with surgical precision.

 

I see possible issues with -IFD0:ImageDescription with Adobe software, but perhaps this can be done. I haven't done much metadata scripting so I'll break out the popcorn and keep an eye on the topic!

 

Chris.SAuthor
Inspiring
February 16, 2023

@Stephen Marsh, ExifTool works brillantly for me, but this is something that I need many of my vendors across the country to do on my behalf. It's easier, and perhaps more foolproof, for them to have this automatically done in their workflows if we distribute a Script that doesn't require the installation of ExifTool and I can ensure it gets done when they edit the files.

 

I believe the problem arises in CG applications (Maya, Cinema4D, Nuke, etc.) that write into these fields (Document Ancestors, Description, Caption-Abstract). Document Ancestors can add 100MB of size to files, and the others can contain sensitive information that shows up in the Get Info window of the finder that I want to have removed.  I don't control the CG side to affect change there, but I can control the 2D Photoshop side, which is where the Photoshop script comes in. Using the Scripts Events Manager within Photoshop, I can have my vendors run the script on every document that is opened so that when they save it these tags will be wiped, ensuring it's gone when the editing is complete. The code below actually works on TIFFs, but files have to be opened/resaved at least twice on PSB/PSDs to get rid of all of it. I believe this is because of the ImageDescription and CaptionDescription. Hoping to find a way to make sure it gets wiped the first time. I think xmp.setLocalizedText may be part of the solution.

function removeMetadata() {
    whatApp = String(app.name);
    if(whatApp.search("Photoshop") > 0)  { 
        if(!documents.length) {
        alert("There are no open documents. Please open a file to run this script.")
        return;
        }
        if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
        var xmp = new XMPMeta( activeDocument.xmpMetadata.rawData);
            xmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "DocumentAncestors");
            if (xmp.doesArrayItemExist(XMPConst.NS_DC, "description", 1))
            {
                xmp.deleteArrayItem(XMPConst.NS_DC, "description", 1);
            }
            app.activeDocument.xmpMetadata.rawData = xmp.serialize();
         }
}
removeMetadata();

 

Chris.SAuthor
Inspiring
February 16, 2023

Clarification: The code directly above works the first time for TIFF and PNG, but requires that the file be opened/resaved 2x to work on PSD, PSB and JPG.

 

It appears XMP-dc:Description doesn't get cleared the first time on the PSD, PSB and JPG (however, EXIF:Description and IPTC:caption-abstract does get cleared on the 1st attempt).