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

Script to remove all meta data from the photo

New Here ,
Mar 14, 2019 Mar 14, 2019

Copy link to clipboard

Copied

Hi

I am looking for a Script to remove all meta data from the photo (main issue is camera and lens info)

if i give my  client a flat image with no layers, i can do it while i export from lightroom.

but i want a way to do it while i keep the layers

is there a photoshop script to do that?

Thank you in advance

TOPICS
Actions and scripting

Views

13.9K

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

correct answers 2 Correct answers

Guide , Mar 14, 2019 Mar 14, 2019

#target photoshop

removeXMP();

function removeXMP(){

if(!documents.length) return;

if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var xmp = new XMPMeta( activeDocument.xmpMetadata.rawData);

XMPUtils.removeProperties(xmp, "", "", XMPConst.REMOVE_ALL_PROPERTIES);

app.activeDocument.xmpMetadata.rawData = xmp.serialize();

}

Votes

Translate

Translate
Community Expert , Jul 22, 2020 Jul 22, 2020

As previously mentioned, this can (mostly) be performed using an action, duplicating the layers to a new file. With conditional actions it can gracefully handle a flattened file.  

 

This is performed by duplicating the layers to a new file. NOTE: Paths, alpha channels, guides, colour samplers and other document-level objects will not carry over to the new file (which may be a good thing if this is for a client, they usually don’t require your intermediate “workings”, you are just supplying a la

...

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 14, 2019 Mar 14, 2019

Copy link to clipboard

Copied

Save for web can strip metadata like that.  Adobe Photoshop scripting may treat EXIF  metadata as read only. I never tried to change any Camera metadata its easy to strip.  I think I may have tried to change some EXIF Date taken information one ti,e because the date was set wrong in my Camera. I believe I was not able to or I found an EXIF utility that could change the date a relative number of days so I did not have to script that. The Script I have that process EXIF metadata only read the data. I found lens information was in Adobe Aux metadata I believe the was create by ACR use RAW Files camera maker metadata, the Actual lens was not in EXIF data just the focal length used was. Save For web can strip all metadata or preserve some metadata like copyright information.

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
Guide ,
Mar 14, 2019 Mar 14, 2019

Copy link to clipboard

Copied

#target photoshop

removeXMP();

function removeXMP(){

if(!documents.length) return;

if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var xmp = new XMPMeta( activeDocument.xmpMetadata.rawData);

XMPUtils.removeProperties(xmp, "", "", XMPConst.REMOVE_ALL_PROPERTIES);

app.activeDocument.xmpMetadata.rawData = xmp.serialize();

}

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
Community Expert ,
Mar 14, 2019 Mar 14, 2019

Copy link to clipboard

Copied

I believe after you strip the metadata you still need to save over the original file to remove it from the files. If you want to strip it from the raw files you man need to use the bridge or some utility  application to strip metadata from raw files.   I do not use LR so I do not know what it can do or if it supports scripting.

With Photoshop and his script you could set up an open event handler to strip meda.

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
Community Expert ,
Mar 14, 2019 Mar 14, 2019

Copy link to clipboard

Copied

Hi SuperMerlin,

 

I tested with a layered PSD from a raw camera file and your script appears to only remove XMP metadata, whereas mo54891077​ is looking to remove “all” metadata, but most importantly EXIF/Camera related metadata. There are a couple of key metadata groups that remain, such as IFD0/TIFF (camera make/model info) and EXIF (camera settings info).

 

You know me well enough by now to expect that I am going to post an ExifTool command to perform this task. The following command strips most of the metadata, retaining the ICC profile (including removal of camera make, model and settings):

 

exiftool -all= -CommonIFD0= --icc_profile:all 'full path to file'

 

This ExifTool command line code can “easily” be added to a drag-n-drop icon or other system level automation on either Mac or Windows, without ongoing need to use the CLI and code.

 

(This command is for the Mac OS, Windows would use double straight quote marks around the path to the file)

 

I would not recommend that any metadata is stripped from original camera files and that this is only performed on outgoing copies of the originals.

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
Explorer ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

Hello Stephen!

Now THIS is really what I was looking for!
It's been about 2 years since all my Indesign files suddenly got HUGE, even if my PSDs were small. One thing I realized after reading this topic is that most of the problems came from files I got from other clients, generally on PCs (I'm on a Mac). So, as a former programmer, I imagined that the Metadata inserted on the files via PC got scrambled OR were misread by Indesign on my Mac, resulting in this massive increase in size. For example, my INDD files used to be around 5 to 10Mb... since the problem started, they went up to 80, 100, 140Mb each! And since I use Google Drive for automated sync, that became a major PAIN!

 

So, after investigating ExifTool with a programmer friend, we came to the following result - which is PERFECT for me:

 

Using Automator on my Mac, I started creating a new QUICK ACTION - which is a command that is accessible through the finder itself, right clicking on the files/folders you choose (yes, you can select several, even a folder - in which only the supported files will be processed).

Then, we came to the following configuration for the QUICK ACTION:

Screen Shot 2022-03-25 at 6.24.49 PM.jpg

- First, select the "Files or Folders" in "Finder.app" (please ignore the "Mail.app", that was included by mistake hahaha)

- Next, search and add the "Run Shell Script" step.

- Now here comes the MAIN THING: you MUST change the "Pass input" to "as arguments" - that way it's possible to have all files/folders come in after the exiftool command, or else an error would happen. Observe that the only part you have to worry about is the third line in the code, where I defined the location of exiftool (I did try using without a path, but got errors also!), then "-all= -CommonIFD0=". I didn't include the "--icc_profile:all" part since I DO work with images that have color profiles applied - don't wanna lose that, right? And the INTERESTING part here is the "$f" that comes at the end - which means "put in the names of the files and folders HERE, please!". YES!

- Last but not least, not shown on the image above, I also included the parameter "-overwrite_original”, after I tested this throughly. As it was, I'd get a copy of the files I selected, always... and after doing a lot of checking, I finally decided to use the Overwrite parameter. Now I'm really happy!

 

So just save the file and you'll automatically have it in your right-click menu, under "services".

WHAM!

DONE!

 

PS.: Since you have all those bloated INDD files, remember to do THIS: after you use the exiftool on all the IMAGES placed in your INDD, do a SAVE AS in Indesign and overwrite it. That way, all the information is freshly saved, no trash AT ALL. It was beautiful to see 140Mb Indesign files come down to 5Mb. What a JOY! 😄 

 

Thanks again Stephen! Fantastic TIP!
I hope my collaboration helps people also!

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
Community Expert ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied


@Erik Lingerfelt wrote:

Hello Stephen!

Now THIS is really what I was looking for!
It's been about 2 years since all my Indesign files suddenly got HUGE

 

Hi Erik, I am glad that you found this helpful.

 

There are many ways to remove metadata, including the often problematic bloated photoshop:DocumentAncestors variety.

 

My blogpost covers this in more detail, including how to remove the bloat from InDesign files and PDF files generated with bloated assets that then become "baked" into .indd and .pdf files.

 

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

 

The Save As step to "remove garbage" is also applicable to PageMaker and PDF files as well.

 

I also show Mac users how to automate ExifTool commands directly into the Mac OS Finder here:

 

https://prepression.blogspot.com/2016/12/automator-diy-exiftool-gui-services.html

 

Our shell script codes are different, but they achieve the same end. Thank you for sharing, I like having another option as a backup!

 

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
Community Expert ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

 

@Erik Lingerfelt 

 

I believe that you are inadvertently removing the ICC profiles with the ExifTool code that you posted.

 

The following two arguments in red are quite destructive, broadly removing most common metadata. The argument in green is non-destructive, the double -- hyphen instructs ExifTool to NOT remove any ICC profile related info:

 

exiftool -all= -CommonIFD0= --icc_profile:all '/Users/username/Desktop/icc.psd'

 

Note the following Terminal.app status messages in blue:

 

exiftool -all= -CommonIFD0= --icc_profile:all '/Users/username/Desktop/icc.psd'
1 image files updated

 

exiftool -all= -CommonIFD0= '/Users/username/Desktop/icc.psd'
Warning: ICC_Profile deleted. Image colors may be affected - '/Users/username/Desktop/icc.psd'
1 image files updated

 

This is why I originally wrote:

"The following command strips most of the metadata without breaking the file..."

 

Which in hindsight may have been a little cryptic. I have just updated the original post to make things clearer, sorry for any confusion. ExifTool is a very deep program, the ability to use the double hyphen to "contradict" the command to remove all metadata is a good example of the flexibility of the software.

 

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
Explorer ,
Mar 28, 2022 Mar 28, 2022

Copy link to clipboard

Copied

Oh!! Thanks!!
I do wish to keep the ICC Profiles, yes!
Thanks for the update!

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
Community Expert ,
Mar 14, 2019 Mar 14, 2019

Copy link to clipboard

Copied

I would like to offer a different brute force approach to removing non-XMP metadata such as EXIF – which is a script to “rebuild” a copy of the original layered file without the original document-level metadata.

 

And here is the “final” scripted version which offers more possibilities than the action method:

 

NOTE: The original script code has been removed for reworking...

 

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
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

I thought that the script that I cobbled together from various sources was "bullet-proof", however, I have just found a flaw.

 

Using the Layer > Duplicate Layer feature to move layer content to a new file to avoid copying common file related metadata works fine for a flattened or multi-layered file... I just tested again and a single layer file has issues, whether using the GUI or a script!

 

If the layer is a single layer, it is flattened when duplicated to a new file. This is not too much of a problem if the original layer did not have any canvas transparency, however, I'd like to retain transparency and layer content positioning to the original image/canvas.

 

It is possible to add a temp blank layer to such a single layer file and then select all layers and dupe, however I would then need to remove the temp from both the new file and the original. Surely there is a better way?

 

Can anybody offer code and or advice?

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
People's Champ ,
Jul 16, 2020 Jul 16, 2020

Copy link to clipboard

Copied

1. select all layers

2. make group

3. duplicate to new doc

3. switch to new doc

4. ungroup or remove group

 

It is alleged that this bug is fixed in 21.2.

Photoshop: Duplicating floating layer to new doc flattens the layer
I did not check due to the lack of 21.2.

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
Community Expert ,
Jul 20, 2020 Jul 20, 2020

Copy link to clipboard

Copied

Thanks, so pretty much the same hack as adding a new blank layer to force the dupe to work correctly. I was hoping for something magic! :]

 

I have it sorted now, thanks r-bin...

 

Now I have discovered a different issue to fix!

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
Community Expert ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

As previously mentioned, this can (mostly) be performed using an action, duplicating the layers to a new file. With conditional actions it can gracefully handle a flattened file.  

 

This is performed by duplicating the layers to a new file. NOTE: Paths, alpha channels, guides, colour samplers and other document-level objects will not carry over to the new file (which may be a good thing if this is for a client, they usually don’t require your intermediate “workings”, you are just supplying a layered file if that is the requirement over a flattened file).

 

(action download)

 

Stephen_A_Marsh_0-1714788765404.png

 

I have used “relative” keyboard shortcuts to navigate and select the layers rather than “absolute” recordings.

 

NOTE: The updated script code has been removed for reworking...

 

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
Enthusiast ,
Jan 28, 2024 Jan 28, 2024

Copy link to clipboard

Copied

It's a bit inconvenient to generate new documents. We still need to save it separately.

Can we not generate a new document?

I want to keep operating on the original document.

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
Community Expert ,
Jan 28, 2024 Jan 28, 2024

Copy link to clipboard

Copied

 

quote

It's a bit inconvenient to generate new documents. We still need to save it separately.

 

Duplicating all layers to a new file is a hack, but a very good one, if one wishes to remove all document-level metadata using Photoshop.

 

quote

Can we not generate a new document?

I want to keep operating on the original document.


By @dublove

 

No. You appear to have missed the point of why the layers are duped to a new doc.

 

If the document is the same, then the metadata is the same, so you have to find a way to remove the document-level metadata! This is why the layers are duped, layers don't contain document-level metadata.

 

It would be best for you to work out and script what metadata you can safely remove using Adobe's XMP (I'm pretty sure the EXIF and possibly others can't be removed, therefore all metadata can't be removed, which is why this can't be performed solely with metadata scripting)... Or you can use a 3rd party tool such as ExifTool which can remove all metadata at the document-level.

 

Perhaps with the new UXP scripting environment, there is a way to remove more metadata that isn't available to ExtendScript based scripts.

 

There are legacy scripts for Photoshop and Bridge to allow you to run ExifTool code if you don't want to use the command line or another operating system-based method to call ExifTool.

 

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
Enthusiast ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

Find an available one and do not generate a new document.

It would be great if there were no pop ups.

 

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
Community Expert ,
Apr 09, 2019 Apr 09, 2019

Copy link to clipboard

Copied

mo54891077 I’m curious, has your issue been resolved, is there any feedback etc? If resolved, can you mark the appropriate answer as correct so that others with the same issue know of the fix?

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
Community Expert ,
Nov 03, 2022 Nov 03, 2022

Copy link to clipboard

Copied

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
Community Expert ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

@Herey35101500twuj 

 

There's no script 

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
Enthusiast ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

@Herey35101500twuj 

hello

Where is your updated version?

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

I use EXIFTool. I wrote a script to run EXIFTool in Bridge and Photoshop, so its easy to do. Same issue with lens and camera data.

The EXIFTool command I use is:

-XMP-exifEX:All= -XMP-aux:All= -EXIFIFD:LensInfo= -EXIFIFD:SerialNumber= -EXIFIFD:LensModel= -XMP-xmpMM:All= -EXIF:All= -tagsfromfile @ -EXIF:ImageWidth -EXIF:ImageHeight -EXIF:XResolution -EXIF:YResolution

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
Community Expert ,
Feb 02, 2024 Feb 02, 2024

Copy link to clipboard

Copied

@Herey35101500twuj 

 

This is the second time that you have supposedly posted a script, that isn't there.

 

If you're not a bot, please post the code.

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 ,
Feb 02, 2024 Feb 02, 2024

Copy link to clipboard

Copied

You can't remove lens and camera data with Adobe's XMP tools unless you wipe out ALL XMP data. That's not helpful. And you are likely a bot since you haven't posted the script.

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
New Here ,
Apr 21, 2024 Apr 21, 2024

Copy link to clipboard

Copied

Hello,

Removing metadata from photos, particularly camera and lens information, can be crucial for maintaining privacy or anonymity. While Lightroom offers an option to strip metadata during export, retaining layers complicates the process. Fortunately, there's a solution for Photoshop users.

You can achieve this through a script in Photoshop. However, since metadata handling varies based on file formats and Photoshop versions, you might need to tweak or combine existing scripts to fit your needs perfectly.

I recommend exploring Adobe's official scripting resources, such as the Adobe Developer Connection or Adobe Community forums, to find or request a script tailored to your requirements. Alternatively, you might consider hiring a developer proficient in Photoshop scripting to create a custom solution for you.

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