JSON: \u0000 in ICC_Profile:CharTarget

Started by jst, January 23, 2018, 04:52:44 AM

Previous topic - Next topic

jst

I run ExifTool on Linux.
The tag ICC_Profile:CharTarget in the JSON-output containes a trailing \u0000.
It looks like it should not be part of the value.

This problem occurs with the attached image.
exiftool -j -G -ICC_Profile:CharTarget image.jpg

The attached diff for Version 10.76 fixed this for me.
patch lib/Image/ExifTool/ICC_Profile.pm patch.diff

Quote9.2.14 charTargetTag
...
If the first seven characters are "ICCHDAT", then the remainder of the text shall be a single space followed by
the Reference Name of a characterization data set in the Characterization Data Registry maintained by ICC,
and terminated with a NULL byte (00h). ...
http://www.color.org/specification/ICC1v43_2010-12.pdf

Phil Harvey

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

jst

I noticed that ICC_Profile:CharTarget is not the only tag with a \u0000 problem.

1)
Most \u0000 are trailing in JSON-strings. (e.g. "ABC\u0000\u0000\u0000\u0000").

I added $str =~ s/\0+$//mg to EscapeJSON().
I am not sure if this is the right way, but it is most likely that many JSON-Parser and String-Implementations cannot handle the NULL character, because this indicates the end of a string.

2)
\0+ seems to be the end of a ListEntry for IPTC:DocumentHistory.
Every entry is padded with \0  to 256 characters.
I added ValueConv => '$val =~ s/\0+/\n/g; $val'.
Maybe here is a better way too.

Unfortunately, I am not able to execute exiftool -tagsfromfile f1.jpg -EXIF:UserComment -IPTC:DocumentHistory f2.jpg successfully.
ExifTool prints "Warning: Can't convert value for IPTC:DocumentHistory (no ValueConvInv)" and "Invalid EXIF text encoding for UserComment".
Is there a way to copy invalid tags, so I can upload examples. (I do not want to upload the original files.)

Phil Harvey

#3
How about the attached patch to remove nulls from the JSON output?

- Phil

Edit:  Oh.  I see that you have done a similar thing already (your point number 1).

You can add "ValueConvInv => '$val'," to get rid of the "No ValueConvInv" warning.

For examples, you can copy the entire IPTC or EXIF block containing the questionable information (with -iptc or -exif).
...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 ($).

jst

Is the else-branch really required?
The function returns in the if-branch.

Phil Harvey

You're right.  The "else" isn't necessary.
...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 ($).

jst

I managed to create an example picture for point number 2. (See Attachments)

Phil Harvey

OK, thanks.  I'll apply your patch to deal with 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 ($).

jst

When is the next release version, containing this patches, planned?

Phil Harvey

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

jst

Sorry, I wanted to write production release version.
Is there a date for this?

Phil Harvey

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