Proper use of User Comments

Started by dbertels, November 25, 2010, 08:20:03 PM

Previous topic - Next topic

dbertels

I  have about 200 bytes of information to store in the header that contains propriety optical instrument data such as
... Eye Position=L, IR Illumin.=5, Flash Intens=5, ...
Currently I store it in the UserComment (using C++/CLI) , however when I use exiftool to view the data, it displays "Warning = Invalid EXIF text encoding"
The verbose output is:

| | 13) UserComment = Compile Date=May 29 2010|Compile Time=14:49:08|Image Time=21:02:02|File=MASO7596.TXT|SDcard Copy=Yes|Eye Position=L|IR Illumin.=5|Flash Intens=5|Modes=Normal|X Position=0|Focus Mode=Auto|Focus Pos.=+2.57
  | |     - Tag 0x9286 (204 bytes, string[204]):
  | |         d42e: 43 6f 6d 70 69 6c 65 20 44 61 74 65 3d 4d 61 79 [Compile Date=May]
  | |         d43e: 20 32 39 20 32 30 31 30 7c 43 6f 6d 70 69 6c 65 [ 29 2010|Compile]
  | |         d44e: 20 54 69 6d 65 3d 31 34 3a 34 39 3a 30 38 7c 49 [ Time=14:49:08|I]
  | |         d45e: 6d 61 67 65 20 54 69 6d 65 3d 32 31 3a 30 32 3a [mage Time=21:02:]
  | |         d46e: 30 32 7c 46 69 6c 65 3d 4d 41 53 4f 37 35 39 36 [02|File=MASO7596]
  | |         d47e: 2e 54 58 54 7c 53 44 63 61 72 64 20 43 6f 70 79 [.TXT|SDcard Copy]
  | |         d48e: 3d 59 65 73 7c 45 79 65 20 50 6f 73 69 74 69 6f [=Yes|Eye Positio]
  | |         d49e: 6e 3d 4c 7c 49 52 20 49 6c 6c 75 6d 69 6e 2e 3d [n=L|IR Illumin.=]
  | |         d4ae: 35 7c 46 6c 61 73 68 20 49 6e 74 65 6e 73 3d 35 [5|Flash Intens=5]
  | |         d4be: 7c 4d 6f 64 65 73 3d 4e 6f 72 6d 61 6c 7c 58 20 [|Modes=Normal|X ]
  | |         d4ce: 50 6f 73 69 74 69 6f 6e 3d 30 7c 46 6f 63 75 73 [Position=0|Focus]
  | |         d4de: 20 4d 6f 64 65 3d 41 75 74 6f 7c 46 6f 63 75 73 [ Mode=Auto|Focus]
  | |         d4ee: 20 50 6f 73 2e 3d 2b 32 2e 35 37 00             [ Pos.=+2.57.]
  | | Warning = Invalid EXIF text encoding

My questions are:
1 - What is the cause of this error (It throws it after more than 8 characters)
2 - Is this an appropriate use of userComment?
3 - Can I store this data elsewhere as independent Name: Value entries?

Thanks

Phil Harvey

The Exif 2.3 specification explains this.  The first 8 bytes of the UserComment data specify the encoding.  For ASCII text, this is "ASCII\0\0\0".  For unknown encoding, use all zero bytes ("\0\0\0\0\0\0\0\0").

If you write a UserComment with ExifTool you will see how it works.

There are many places you could put this data, but it depends on your application.  Typically, proprietary information like this is written to the maker notes, which often contain text similar to this.

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

dbertels

Thanks for taking the time to answer this Phil. It's a great help.

As an interesting side-note: When I write the UserComment data wrongly as in my original post, the data actually appears in windows explorer when the "Comments" header is activated (at least in Vista). When I add the ASCII code as suggested, the text is hidden, though the data is there as it can be read with ExifTools's verbose mode.

Phil Harvey

Windows Vista is notoriously bad at metadata handling, so I don't think it is worthwhile wasting any brain cycles trying to figure out what it is doing here.  You can't go wrong in the long run if you stick to the Exif standard.

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