You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When loading some images with MagickImage and writing them to a stream or saving ToByteArray the loaded exif metadata is no longer written to the output. This causes some things like orientation information to be lost.
This appears to be a regression from earlier versions of Magick.NET. Specifically, we were previously using 13.4 before upgrading and seeing this new behavior. It seems likely that the image is corrupt in some way (at the very least looks like it doesn't have the EOI marker) but it was great that MagickImage handled these corrupt images from our users better in the previous version.
We have a workaround for orientation by calling AutoOrient before persisting to a byte array but I don't know if there is other important metadata that could be lost in this process.
Steps to Reproduce
The following output samples are from using the image attached to this as input and the provided script.
14.2 output
Before
Has Exif Profie: True
Has Color Profie: True
After
Has Profie: False
Has Color Profie: True
13.4 output
Before
Has Exif Profie: True
Has Color Profie: True
After
Has Profie: True
Has Color Profie: True
Test code
using var image = new MagickImage(inputFile);
Console.WriteLine("Before");
Console.WriteLine($"Has Exif Profie: {(image.GetExifProfile() != null)}");
Console.WriteLine($"Has Color Profie: {(image.GetColorProfile() != null)}");
var bytes = image.ToByteArray();
using var reloadedImage = new MagickImage(bytes);
Console.WriteLine();
Console.WriteLine($"After");
Console.WriteLine($"Has Profie: {(reloadedImage.GetExifProfile() != null)}");
Console.WriteLine($"Has Color Profie: {(reloadedImage.GetColorProfile() != null)}");
reloadedImage.Write(outputFile);
The text was updated successfully, but these errors were encountered:
It looks like you found an edge case situation. The length of your profile is the maximum length an exif profile can have in a jpef file. But we had an incorrect check in the code of ImageMagick. I just pushed a patch to fix that and this issue will be resolved in the next release. I will add a unit test at a later point to make sure this stays fixed.
Magick.NET version
14.2
Environment (Operating system, version and so on)
Windows
Description
When loading some images with
MagickImage
and writing them to a stream or savingToByteArray
the loaded exif metadata is no longer written to the output. This causes some things like orientation information to be lost.This appears to be a regression from earlier versions of
Magick.NET
. Specifically, we were previously using 13.4 before upgrading and seeing this new behavior. It seems likely that the image is corrupt in some way (at the very least looks like it doesn't have theEOI
marker) but it was great thatMagickImage
handled these corrupt images from our users better in the previous version.We have a workaround for orientation by calling
AutoOrient
before persisting to a byte array but I don't know if there is other important metadata that could be lost in this process.Steps to Reproduce
The following output samples are from using the image attached to this as input and the provided script.
14.2 output
13.4 output
Test code
The text was updated successfully, but these errors were encountered: