How to remove an entry from the ICC Header Tag "ProfileCMMType"

Started by Leven, May 17, 2017, 02:58:14 AM

Previous topic - Next topic

Leven

Hello, I need some help with the embedded ICC-Profiles in my TIF-Files. I know that Exiftool has only limited possibilities to alter ICC-Profiles but maybe there is a workaround...
Ok, I have to prepare thousands of TIF-Files to make them ready for long term archiving. The rules are very strict. And now the problem:
I need to remove wrong (not allowed) entries from "ProfileCMMType". Is there any way to solve this issue with Exiftool? At the moment I'm using
-r -overwrite_original -photoshop:all= -IPTC:all= -XMP:all= -Artist= -padding= -PageNumber= -HostComputer= -PageName= -ModifyDate= -filename=%%.8nc.%%e -ext tif to process the data.
Or do you know another way to solve the problem?
Thank you!!!
Leven

Phil Harvey

Hi Leven,

You want to remove individual ICC profile elements?  Or remove complete illegal ICC profiles?

The former isn't possible with ExifTool.  But could you instead replace the entire ICC_Profile with an acceptable one?:

exiftool -if "$SOMETAG =~ /CONTAINS THIS/" "-icc_profile<=A_GOOD_PROFILE.ICC" DIR

Or to delete the unacceptable profile:

exiftool -if "$SOMETAG =~ /CONTAINS THIS/" -icc_profile= DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Leven

Hi Phil,
thank you for your answer. Unfortunatly I have to keep the ICC profile (which is o.k. except the wrong tag). Deleting the profile is not possible because the colors on the display will show up wrong (i think this caused by the larger color space of the scanning device).
I will try to extract the profile and maybe I will find a way to correct the tag with another tool. Replacing the old one with the corrected one should be possible.
Do you probably know a tool for this task?

Thanks again!
Leven

Phil Harvey

Hi Leven,

This should work, but unfortunately I can't help you with finding a tool to modify the profile.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Color.org has this list and this list of tools for working with profiles.  The second link is open source programs.  I'm not sure how up to date it may be or how well any of them work.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Leven

Thank you very much for the help. I will try to find a tool and will report the results here.

Leven

 :) Hi, finally i found a way to edit the ICC header. I used ICCXML to convert .icm to .xml. After changing the wrong value you can convert the xml back to .icm and than I used Phils replacement code. You can find ICCXML here https://sourceforge.net/projects/iccxml/ and informations about the needed libraries https://github.com/InternationalColorConsortium/RefIccMAX/blob/master/IccXML/README.

But I have a new question. My code is now. -r -photoshop:all= -IPTC:all= -XMP:all= -Artist= -padding= -PageNumber= -HostComputer= -PageName= -ModifyDate= -if "$ProfileCMMType =~ /APPL/" "-icc_profile<=C:\TIFF_TOOLS\Extract_ICC\extracted\OS14000_korr.icm" -ext tif .
The code changes only the TIFFs where the ICC profile is wrong (/APPL/). All other files are ignored but have to processed too (i.e. removing the artist tag). Is there a way to do this in one pass? At the moment I am using this batch:
C:\TIFF_TOOLS\EXIFTOOLGUI\exiftool.exe %~f1 -r -overwrite_original -if "$ProfileCMMType =~ /APPL/" "-icc_profile<=C:\TIFF_TOOLS\Extract_ICC\extracted\OS14000_korr.icm" -ext tif
C:\TIFF_TOOLS\EXIFTOOLGUI\exiftool.exe %~f1 -r -overwrite_original -photoshop:all= -IPTC:all= -XMP:all= -Artist= -padding= -PageNumber= -HostComputer= -PageName= -ModifyDate= -filename=%%.8nc.%%e -ext tif


But this takes much more time. Is there a better way to do this?

Thanks again!
Leven

Phil Harvey

Hi Leven,

OK, this is a bit tricky, but the following command will do your processing in a single pass:

C:\TIFF_TOOLS\EXIFTOOLGUI\exiftool.exe "-icc_profile<=C:\TIFF_TOOLS\Extract_ICC\extracted\OS14000_korr.icm" "-icc_profile<${icc_profile;$self->GetValue('ProfileCMMType')=~/APPL/ and $_=undef}" -photoshop:all= -IPTC:all= -XMP:all= -Artist= -padding= -PageNumber= -HostComputer= -PageName= -ModifyDate= -filename=%%.8nc.%%e -ext tif -r -overwrite_original %~f1

The trick I used is to copy back the original ICC_Profile afterwards only if the ProfileCMMType doesn't contain "APPL".  Otherwise the ICC_Profile gets set from the external file.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Leven

Hi Phil,
thanks again! I will try the code when I am back in office on monday. But I'm sure it will work :)!
Leven

Leven

Hi Phil,

it is getting more and more tricky! Your code works fine for images with embedded ICC profiles! But sometimes there are images without profiles. In this case the code writes the corrected ICC profile into the "empty" images but they should left empty. Is there a way to change the command to account for this case?

Thanks!
Leven

Phil Harvey

Hi Leven,

Right.  That is a problem.

This solution is even a bit trickier:

C:\TIFF_TOOLS\EXIFTOOLGUI\exiftool.exe "-icc_profile<${ProfileCMMType;/APPL/ or return $_=undef; open(INFILE,'C:\TIFF_TOOLS\Extract_ICC\extracted\OS14000_korr.icm') and binmode(INFILE) and read(INFILE,$_,1e6) and close(INFILE)}" -photoshop:all= -IPTC:all= -XMP:all= -Artist= -padding= -PageNumber= -HostComputer= -PageName= -ModifyDate= -filename=%%.8nc.%%e -ext tif -r -overwrite_original %~f1

This command should work for OS14000_korr.icm up to 1 MB in size.  For a larger external profile you would have to increase the "1e6" constant in the read() function call.

- Phil

Edit: Added binmode() call to avoid unpleasant surprises.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Leven

Fantastic! It works great! I am glad for your help and I hope that I now have all I need for correcting this huge amount of tif files.
Thanks a lot! :)
Leven