I'm trying to fix a UserComment on photo that is uploading into a Medical Records system. Everytime I update the comment I get this:
18) UserComment = ASCIIGCM_TAG
| | - Tag 0x9286 (15 bytes, undef[15]):
| | 188e: 41 53 43 49 49 00 00 00 47 43 4d 5f 54 41 47 [ASCII...GCM_TAG]
I want the UserComment to be undefined. I have the following config file, but it's not working.
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Exif::Main' => {
0x9286 => {
Name => 'UserComment',
Format => 'undef',
Writable => 'undef',
RawConv => 'Image::ExifTool::Exif::ConvertExifText($self,$val,1)',
RawConvInv => 'Image::ExifTool::Exif::EncodeExifText($self,$val)',
},
} ,
) ;
I need the tag to look like the following. Can anyone help?
18) UserComment = GCM_TAG
| | - Tag 0x9286 (15 bytes, undef[15]):
| | 188e: 41 53 43 49 49 00 00 00 47 43 4d 5f 54 41 47 [...GCM_TAG]
Acutally here is the incorrect tag:
| | 18) UserComment = ASCIIGCM_TAGAC275348100WOUND_PHOTO589723
| | - Tag 0x9286 (43 bytes, undef[43]):
| | 1872: 41 53 43 49 49 00 00 00 47 43 4d 5f 54 41 47 41 [ASCII...GCM_TAGA]
This is what the tag should look like:
| | 18) UserComment = GCM_TAGAC275348100WOUND_PHOTO589723
| | - Tag 0x9286 (640 bytes, undef[640]):
| | 03f2: 00 00 00 00 00 00 00 00 47 43 4d 5f 54 41 47 00 [........GCM_TAG.]
Try this for a config file:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Exif::Main' => {
0x9286 => {
Name => 'UserComment',
Format => 'undef',
Writable => 'undef',
RawConv => 'Image::ExifTool::Exif::ConvertExifText($self,$val,1)',
RawConvInv => '("\0"x8) . $val',
},
},
);
1; #end
This should do what you want provided that you write the exact binary value that you want. (I don't know what exiftool command you are using to write UserComment.)
- Phil
Thanks for the help, Phil! I think it's close. The command creates the UserComment correctly. However, it still won't load the file. It looks like there is an extra bit (00) between the fields when it works correctly. The top example below is the result of using the config file and running the command exiftool -UserComment=GCM_TAGAC275117786WOUND_PHOTO589723 WC030577~u20170412125219837.JPG
| | 18) UserComment = GCM_TAGAC275117786WOUND_PHOTO589723
| | - Tag 0x9286 (43 bytes, undef[43]):
| | 1872: 00 00 00 00 00 00 00 00 47 43 4d 5f 54 41 47 41 [........GCM_TAGA]
| | 1882: 43 32 37 35 31 31 37 37 38 36 57 4f 55 4e 44 5f [C275117786WOUND_]
| | 1892: 50 48 4f 54 4f 35 38 39 37 32 33 [PHOTO589723]
This second example is one straight from the camera that uploaded correctly. You can see the (00) bit between each field.
| | 18) UserComment = GCM_TAGAC271604712WOUND_PHOTO589723
| | - Tag 0x9286 (640 bytes, undef[640]):
| | 03f2: 00 00 00 00 00 00 00 00 47 43 4d 5f 54 41 47 00 [........GCM_TAG.]
| | 0402: 41 43 32 37 31 36 30 34 37 31 32 00 57 4f 55 4e [AC271604712.WOUN]
| | 0412: 44 5f 50 48 4f 54 4f 00 35 38 39 37 32 33 00 00 [D_PHOTO.589723..]
| | 0422: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [................]
| | 0432: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [................]
| | [snip 560 bytes]
I thought this might be the case. You can't generate binary data on the command line. You will need to prepare a file containing the binary data first, then use a command like this to insert it:
exiftool -config my.config "-usercomment<binfile.dat" FILE
Now the problem remains about how to create "binfile.dat". You can use ExifTool to generate this file from an image that already contains this information, but you will need to modify the config file:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Exif::Main' => {
0x9286 => {
Name => 'UserComment',
Format => 'undef',
Writable => 'undef',
RawConv => 'substr($val,8)',
RawConvInv => '("\0"x8) . $val',
},
},
);
1; #end
and generate "binfile.dat" with this command:
exiftool -config my.config -usercomment -b SRCFILE > binfile.dat
Either that, or copy the data directly from one image file to another:
exiftool -config my.config -tagsfromfile SRCFILE -usercomment FILE
- Phil