News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Is the ICC JPEG Embedding Spec Correct?

Started by clanmills, September 13, 2016, 08:48:43 AM

Previous topic - Next topic

clanmills

Phil

I'm adding ICC profile support to Exiv2 for the upcoming v0.26 release.  I think there's an error in the ICC document:  ICC1v43_2010-12.pdf <— Annex B contains embedding spec

It says that the profile should be embedded in an APP2 Segment with the initial bytes of the data set to ICC_PROFILE\0 (12 bytes) followed by a chunk counter (one byte) and total chunks (one byte).  So, the first 14 bytes are defined.  I assume the remainder of the segment is profile data. However, from testing using iccDumpProfile, there seem to be 4 padding bytes (2 before the data and 2 after).

I've written a little script to download all your test bundles (such as Canon.tar.gz).  You have 6577 JPGs of which 92 have embedded ICC profiles.  To successfully run iccDumpProfile on these profiles, I have to strip the 4 padding bytes.

What do you think?

Phil Harvey

Look at section 7.2 of ICC1v43_2010-12.pdf.  The first 4 bytes are the profile size.  I think the problem here is iccDumpProfile.

If you use ExifTool to extract the profile, then the first 4 bytes output are the profile size.  These come immediately after the 14-byte header in JPEG images.

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

clanmills

Thanks Phil, I knew you'd know.  And yes, of course, I should be using exiftool in my testing as well as iccDumpProfile.

Not good that I can't trust iccDumpProfile!  I'll report a bug to the ICC people.  I'd like an enhancement to iccDumpProfile to read profiles from stdin.  Then I can pipe the data from Exiv2 into the iccDumpProfile.  Something like:$ exiv2 -eC- foo.jpg | iccDumpProfile -
-eC = Extract Color Profile (to foo.icc)
-eC- = Extract Color Profile to stdout


As always, Thank You for your help.

Phil Harvey

I don't know what iccDumpProfile has over ExifTool, but you can of course pipe to ExifTool like this:

exiv2 -eC- foo.jpg | exiftool -

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

clanmills

Ah.  I don't know why I'm bothering with iccDumpProfile.  I'm only using it in the terminal.  It's not used by our test suite.

I feel, (English accent on) it isn't quite cricket (restore normal voice) to use exiftool in testing Exiv2.

I built iccDumpProfile a while ago and it seemed OK.  Last weekend, I discovered it no longer builds on MacOS-X 10.11.  The Apple people have changed the SDK and removed support for CMmumble APIs.  (CM = Color Murderer or something).  It's impossible to use earlier SDKs.  So iccDumpProfile doesn't even build any more on MacOS-X.  Now if only the ICC people supported and maintain their code with the diligence of you and I.  (and our modesty of course).

Phil Harvey

Quote from: clanmills on September 13, 2016, 10:29:23 AM
I feel, (English accent on) it isn't quite cricket (restore normal voice) to use exiftool in testing Exiv2.

Jolly good then. :P

Quote(and our modesty of course).

It's easy to be modest when you're the best. :)

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