ICC Profile support for BMP files

Started by Tanner_H, December 01, 2016, 01:26:40 PM

Previous topic - Next topic

Tanner_H

Hi Phil.  Thank you for your ongoing (amazing!) work on ExifTool.

Just a small feature request, if I may.  BMP file support in ExifTool is currently very rudimentary, which is fine -- BMP files themselves are rudimentary, after all.

One unfortunate gap in ExifTool's coverage, however, is extracting ICC profiles from BMP files.  BMP files that use a v5 header can embed full ICC profiles, and even the older v4 header contains some basic colorimetry data that may be worth extracting as metadata (XYZ endpoints and gamma values for each RGB channel, for example).

The BMP article on Wikipedia lists the sizes between different BMP headers, which makes it easy to determine the presence of a standard header vs the "newer" v4 or v5 headers: https://en.wikipedia.org/wiki/BMP_file_format#DIB_header_.28bitmap_information_header.29 .  (I say "newer" because these headers are still 20+ years old.)

Microsoft's documentation shows where the ICC profile size and offset can be found in the newer v5 headers: https://msdn.microsoft.com/en-us/library/dd183381(v=vs.85).aspx .  The "Remarks" section provides very specific details on how to retrieve the ICC profile, if present.

If you are interested, here is the Microsoft documentation for the smaller v4 BMP header, which is also commonly seen "in the wild": https://msdn.microsoft.com/en-us/library/dd183380(v=vs.85).aspx

While BMP files have largely been replaced by more efficient file types, the format is still a mainstay for Windows developers, particularly for interop between programs (via e.g. the Windows clipboard).  Some applications do attach ICC profiles to BMP files, and it would be great if ExifTool could parse out the ICC profile from such BMP files, when it exists.

If it would be helpful, I can provide some BMP files with embedded profiles for testing.  Note that anyone can generate BMP files like this with the open-source "GIMP" software (https://www.gimp.org/).  GIMP embeds color space information inside BMP files by default.  (You can forcibly prevent this behavior by selecting the "Compatibility Options > do not write color space information" option at export time to prevent this, as well.)

Thank you in advance for any commentary/feedback on this feature.

Phil Harvey

Thanks for the suggestion.  I'll look into this when I can (probably in a few weeks).  If you could post sample BMP's containing the information you want extracted it would save me some time.

- 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 ($).

Tanner_H

Thank you for the swift reply, Phil.  I've attached a zip file with three different test BMPs, all with the v5 header.  Two have embedded ICC profiles; one does not.

(One of the files may be GPL; I took it from Jason Summers BMP test suite, which is very helpful for generating BMP test files: https://github.com/jsummers/bmpsuite .  I found Jason's test suite through Firefox's recent work on improved BMP decoding: https://blog.mozilla.org/nnethercote/2015/11/06/i-rewrote-firefoxs-bmp-decoder/)

Please let me know if any other information or test files would be helpful.

Phil Harvey

OK, I've implemented this.  ExifTool 10.37 will support the additional metadata available in BMP V5 images (incl. ICC_Profile).  I expect to release this version in a couple of weeks.

Thanks for the suggestion, samples, and pointers.

- 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 ($).

Tanner_H

My pleasure.  Thank you for your swift reply and for implementing this so quickly.  Happy holidays!