I've successfully been updating the comment field in many images until I tried in an image from a Google Pixel phone.
Here's a sample image: https://www.edcint.co.nz/tmp/PXL_20210205_230623035.jpg
This is successful:
my $success=$exifTool->SetNewValue('UserComment', $comment,Replace=>1);
This is not successful:
$success = $exifTool->WriteInfo($file);
A check of the file using the command line tool shows that no comment has been written
Strangely, using the command line tool (even at v12.16), this works:
exiftool -comment="1" /s/TEMP/PXL_20210205_230623035.jpg
I was using v12.16 and so I tried v12.18 but same result.
Is this a bug?
UserComment and Comment are two completely different tags. The first is part of the EXIF block. The second is the jpeg comment field, specific to jpegs only.
I tried setting the UserComment on your example image on the command line with this command
exiftool -P -overwrite_original -usercomment=test Y:\!temp\ccccc\o\PXL_20210205_230623035.jpg
and it came back with this error
Error: [minor] Incomplete extended XMP (GUID 7504876AC6DC4F17F78267AF27559BED)
StarGeek posted while I was composing, but here it is anyway...
Writing Comment works. Writing UserComment doesn't. This is because there is a problem with the XMP and UserComment also exists in XMP.
> exiftool PXL_20210205_230623035.jpg -usercomment=test
Error: [minor] Incomplete extended XMP (GUID 7504876AC6DC4F17F78267AF27559BED) - a.jpg
0 image files updated
1 files weren't updated due to errors
To write this, either specify EXIF:UserComment, or use the API IgnoreMinorErrors option.
- Phil
Great help and so quickly.
My fault for getting the fields mixed up.
I have used the following for now and it works.
%Image::ExifTool::UserDefined::Options = (
IgnoreMinorErrors=> 1,
);