IPTC: Envelope values "Character set" and "ModelVersion" result in broken Codepage
See original GitHub issueRun this snippet with Magick.NET 7.22.3.0:
var raw = new byte[]
{
// A naked 10x10 pixel jpg.
0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x48, 0x00,
0x48, 0x00, 0x00, 0xFF, 0xDB, 0x00, 0x43, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01,
0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x03, 0x02, 0x02, 0x02, 0x02, 0x05, 0x04, 0x04, 0x03, 0x04,
0x06, 0x05, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x07, 0x09, 0x08, 0x06, 0x07, 0x09, 0x07, 0x06,
0x06, 0x08, 0x0B, 0x08, 0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x06, 0x08, 0x0B, 0x0C, 0x0B, 0x0A, 0x0C,
0x09, 0x0A, 0x0A, 0x0A, 0xFF, 0xDB, 0x00, 0x43, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x05, 0x03,
0x03, 0x05, 0x0A, 0x07, 0x06, 0x07, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x0A, 0x00, 0x0A, 0x03, 0x01, 0x22,
0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xFF, 0xC4, 0x00, 0x15, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0xFF, 0xC4, 0x00, 0x14,
0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0xC4, 0x00, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xC4, 0x00, 0x14, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xDA, 0x00, 0x0C, 0x03, 0x01,
0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3F, 0x00, 0xBF, 0x80, 0x03, 0xFF, 0xD9
};
using (var stream = new MemoryStream())
{
using (var image = new MagickImage(raw))
{
var iptcProfile = new IptcProfile();
iptcProfile.SetValue(IptcTag.Byline, "Vašek");
image.SetProfile(iptcProfile);
image.Write(stream);
}
//Debug.WriteLine(string.Join(" ", stream.ToArray().Select(@byte => $"{@byte:X2}")));
File.WriteAllBytes("test.jpg", stream.ToArray());
}
results in broken metadata (e.g. on left IrvanView doesn’t recognize UTF-8 / on the right IrvanView saves the IPTC with Character set and ModelVersion):
I drilled down the issue to the IPTC profile:
wrong (Magick.NET):
FF ED 00 28 50 68 6F 74 6F 73 68 6F 70 20 33 2E 30 00 38 42 49 4D 04 04 00 00 00 00 00 0B 1C 02 50 00 06 56 61 C5 A1 65 6B 00
correct:
FF ED 00 36 50 68 6F 74 6F 73 68 6F 70 20 33 2E 30 00 38 42 49 4D 04 04 00 00 00 00 00 1A 1C 01 5A 00 03 1B 25 47 1C 01 00 00 02 00 04 1C 02 50 00 06 56 61 C5 A1 65 6B
Marker Length P h o t o s h o p 3 . 0 8 B I M Length Character set ModelVersion Byline V a š e k EvenPadding
Is it possible to add this IPTC Envelope data? Maybe “Character set” is sufficient but I didn’t find any specification.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Character set not copied when copying IPTC data between ...
I have a source file with this IPTC data (stripped): Envelope Record Version : 4. Coded Character Set : UTF8
Read more >write IPTC:CodedCharacterSet tag when creating/updating ...
Quote In the (Default) setting IMatch (and ExifTool) assume that the character set used for IPTC is UTF-8 if the IPTC record in...
Read more >Image::ExifTool IPTC UTF-8 Support?
The value of setting CodedCharacterSet is that it informs other applications that your IPTC strings contain UTF-8 characters. As far as ExifTool is...
Read more >IPTC datasets
Tag (hex) Tag (dec) Key Type M. R. Min. bytes Max. bytes
0x0000 0 Iptc.Envelope.ModelVersion Short Yes No 2 2
0x0005 5 Iptc.Envelope.Destination String No...
Read more >UTF-8 characters not displaying properly from JPEG IPTC ...
When reading the IPTC data from an image, UTF-8 accented characters are not displaying properly when reading them via PHP. For example: é,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The new release has been published. Can you give it a try with that release?
Thanks for reporting this. I could add the
IPTC Envelope
.I did find this about the character set (https://www.iptc.org/std/IIM/4.1/specification/IIMV4.1.pdf):
Your bytes contain this:
The
APPENDIX C
is also in the document but I don’t understand what is written there. I could probably add what is written by IrvanView for now.This also means I made a design mistake when creating
IIptcProfile
andIIptcValue
. The encoding should be moved from the value to the profile. For now I can probably only supportUTF8
and allow setting it at a later moment when I figure out how to write other encodings.