How to remove xmp metadata?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

mariaprabudass

How to remove xmp metadata?

Post by mariaprabudass »

Hello sir,

I need to remove the "XMP metadata" information in the tiff(photoshop) files via scripting(JavaScript or vb script). Is it possible? Kindly advice me. If possible, please provide examples.

Thanks for looking into this..

Regards,
Maria Prabudass
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: How to remove xmp metadata?

Post by Kukurykus »

Code: Select all

fle = File('~/desktop/someFile.tif'); if (!ExternalObject.AdobeXMPScript)
	ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript')
xmp = new XMPFile(fle.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE)
xmp.putXMP(new XMPMeta()), xmp.closeFile(XMPConst.CLOSE_UPDATE_SAFELY)
In case of tiff the removed metadata will be replaced by empty lines, so the size of the file will be the same, though read much faster. To make it is read faster while the size reflects only the actual content you have to resave the file by Photoshop, so better if instead of above code you'll use this one on open file (which then you save):

Code: Select all

if (!ExternalObject.AdobeXMPScript)
	ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript')

activeDocument.xmpMetadata.rawData = new XMPMeta()