-
So, I am trying to save an Exif UserComment to a .webp image like this:
It does work (partially), but I have some issues. First of all, I think that I'm doing SetValue wrong somehow, since I'm not setting TValueType for SetValue. When I try to do that, like this: Secondly, with the way I do it, if I then open the image in GIMP, I can see that the charset isn't set correctly since it says "charset=InvalidCharsetId l wonderful little cømment" for the comment of the image. Probably related to how I do SetValue, or what am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The format is a byte array because the value is an "undefined type" so you will need to write the bytes yourself. I did find this PR that contained some information about that you should do: SixLabors/ImageSharp#1919. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. I went down a rabbit hole and have come to the conclusion that everyone just adds 8 null bytes before the text (i.e. set it to the "undefined character code" per the standard), even though there is a Unicode character code that specifies UTF-8 per version 3.0 of the EXIF standard. If I write the Unicode character code as one would think one should, then most tools either read it incorrectly ("坯湤敲晵氠睯湤敲晵氠汩瑴汥쎸浭敮" in ExifTool) or read the character code as if it were a part of the text ("charset=Unicode Wonderful wonderful little cømment" in GIMP). Magick.NET reads the character code regardless, but it's not visible when converted to a string if set to the Unicode charset, since that's just null bytes which get ignored. If set to Unicode, the UserComment is read like this: "UNICODEWonderful wonderful little cømment". So, I'll just add 8 null bytes before the comment x) |
Beta Was this translation helpful? Give feedback.
The format is a byte array because the value is an "undefined type" so you will need to write the bytes yourself. I did find this PR that contained some information about that you should do: SixLabors/ImageSharp#1919.