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

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

Participant ,
Feb 15, 2023 Feb 15, 2023

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

 

 

TOPICS
Actions and scripting
2.6K
Translate
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 ,
Feb 15, 2023 Feb 15, 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!

 

Translate
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 ,
Feb 16, 2023 Feb 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();

 

Translate
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 ,
Feb 16, 2023 Feb 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).

Translate
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
Community Expert ,
Feb 16, 2023 Feb 16, 2023
quote

@Stephen Marsh, Document Ancestors can add 100MB of size to files


By @Chris.S

 

You can find scripts for photoshop:DocumentAncestors here:

 

https://prepression.blogspot.com/2017/06/metadata-bloat-photoshopdocumentancestors.html

 

Translate
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 ,
Feb 16, 2023 Feb 16, 2023

You can find scripts for photoshop:DocumentAncestors here:

https://prepression.blogspot.com/2017/06/metadata-bloat-photoshopdocumentancestors.html

By @Stephen Marsh

 

Thanks @Stephen Marsh. I already had that figured out how to handle the Document Ancesters in this script, but had removed it for this post since it was working and I didn't want to add the extra layer of complexity. However, I appreciate the link as it has a lot of helpful information, and I like the learning and having options. Also, I actually see something there that may help me with this issue, so will test that out to see if it helps.

 

Regarding removal of all metadata, yes that would be too excessive in this case. Contrary to my note about not using ExifTool for all our vendor sites, I am using ExifTool in combination with Filemaker to QC all the metadata in files they provide to us to make sure they were built according to spec (bit depth, profile, color space, etc.)

Translate
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
Community Expert ,
Feb 16, 2023 Feb 16, 2023

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

Translate
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 ,
Feb 16, 2023 Feb 16, 2023
LATEST

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.

Translate
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