-
-
Notifications
You must be signed in to change notification settings - Fork 888
Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp
- I have verified if the problem exist in both
DEBUG
andRELEASE
mode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
2.1.3
Other ImageSharp packages and versions
None
Environment (Operating system, version and so on)
Windows 10 21H2
.NET Framework version
6
Description
The IPTC text tags on jpg files that contains non-English characters are displayed incorrectly on external apps, even though they are written using the default utf-8 encoding.
The use of utf-8 encoding is not indicated on the envelope record. External apps may use that record to identify the encoding and can assume the use of "ascii" encoding if not present.
I've written a patch that adds the optional tag (1:90 Coded Character Set) that indicates the use of utf-8 encoding on the text tags and solves this case. I can open a pull request or share the code with you.
Steps to Reproduce
- Load any jpg file.
- Write any text tag on IptcProfile, for example: Caption using non-English characters, such as "ESPAÑA".
- Save the changes on a new file.
- Open the new file with Irfanview, menu "Image -> Information", button "IPTC info".
- The caption tag shows "ESPAÑA" instead of "ESPAÑA".
void Test()
{
const string fileInput = "c:\\temp\\input1.jpg"; // whatever jpg file
const string fileOutput = "c:\\temp\\output1.jpg";
using (SixLabors.ImageSharp.Image img = SixLabors.ImageSharp.Image.Load(fileInput))
{
if (img.Metadata.IptcProfile == null)
{
img.Metadata.IptcProfile = new IptcProfile();
}
img.Metadata.IptcProfile.SetValue(IptcTag.Caption, "ESPAÑA");
img.SaveAsJpeg(fileOutput, new JpegEncoder() { Quality = 90 });
}
}
I've fixed this adding the 1:90 "Coded Character Set" to the Envelope record on IptcProfile.UpdateData() method.
Images
br3aker