Author Topic: JSON: \u0000 in ICC_Profile:CharTarget  (Read 2754 times)

jst

  • Newbie
  • *
  • Posts: 6
JSON: \u0000 in ICC_Profile:CharTarget
« on: January 23, 2018, 04:52:44 AM »
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

Quote
9.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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18006
    • ExifTool Home Page
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #1 on: January 23, 2018, 07:08:02 AM »
Great, thanks for this patch!

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jst

  • Newbie
  • *
  • Posts: 6
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #2 on: February 01, 2018, 09:08:44 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18006
    • ExifTool Home Page
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #3 on: February 01, 2018, 10:20:11 AM »
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).
« Last Edit: February 01, 2018, 10:39:41 AM by Phil Harvey »
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jst

  • Newbie
  • *
  • Posts: 6
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #4 on: February 01, 2018, 10:49:31 AM »
Is the else-branch really required?
The function returns in the if-branch.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18006
    • ExifTool Home Page
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #5 on: February 01, 2018, 10:54:18 AM »
You're right.  The "else" isn't necessary.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jst

  • Newbie
  • *
  • Posts: 6
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #6 on: February 01, 2018, 11:47:37 AM »
I managed to create an example picture for point number 2. (See Attachments)

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18006
    • ExifTool Home Page
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #7 on: February 01, 2018, 03:14:05 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jst

  • Newbie
  • *
  • Posts: 6
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #8 on: February 13, 2018, 03:56:40 AM »
When is the next release version, containing this patches, planned?

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18006
    • ExifTool Home Page
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #9 on: February 13, 2018, 07:25:21 AM »
It was released on Sunday.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jst

  • Newbie
  • *
  • Posts: 6
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #10 on: February 13, 2018, 07:40:11 AM »
Sorry, I wanted to write production release version.
Is there a date for this?

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18006
    • ExifTool Home Page
Re: JSON: \u0000 in ICC_Profile:CharTarget
« Reply #11 on: February 13, 2018, 07:41:29 AM »
Probably in about a week or so.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).