dlemstra / dlemstra/Magick.NET
Incorrect ExifIfds for ImageHistory exif tag (or conversion issue from System.Drawing.Bitmap)
- Dominant language
- C#
- Stars
- 4k
- Forks
- 451
- Avg merge
- 11h 55m
- Merged PRs (30d)
- 3
Description
### Magick.NET version
14.14.0
### Environment (Operating system, version and so on)
Windows 11
### Description
When converting a System.Drawing.Bitmap into a MagickImage in Magick.NET, the EXIF tag ImageHistory (0x9213) is assigned a different ExifIfd compared to when the same image is loaded directly using Magick.NET.
Specifically:
When loading the image directly with new MagickImage("file.jpg"), the tag ImageHistory is assigned to ExifIfds.Exif.
When loading the image through System.Drawing.Bitmap and then converting it to MagickImage, the same tag is assigned to ExifIfds.Ifd0.
The tag value itself remains identical in both cases, but the ExifIfd differs depending on the input pipeline.
This inconsistency indicates that EXIF IFD assignment is not normalized across different loading paths. The Bitmap-based conversion path appears to lose or ignore original EXIF IFD grouping information, resulting in a fallback or default assignment to Ifd0.
As a result, metadata comparisons that include ExifIfd (for example equality checks between tags or profiles) will fail even though the underlying EXIF data is identical.
The issue is specific to the conversion pipeline involving System.Drawing.Bitmap and does not occur when images are loaded directly through Magick.NET.
### Steps to Reproduce
Create a MagickImage.
Set the exif tag "ImageHistory" to a value.
Save to Test.jpg
=> Alternatively, you can use attached Test.jpg file, which contains some ImageHistory exif data.
Create a System.Drawing.Bitmap from this file.
Convert to MagickImage.
Call GetExifProfile().GetValue(ExifTag.ImageHistory) => you get null.
ImageHistory is present if exifProfile, with the correct tag value (0x9213) but ExifIfds set to "Ifd0" instead of expected "Exif"
### Images
[Test.jpg](https://github.com/user-attachments/assets/e2434fd7-490d-465c-8b7c-49871a814e17)
Contributor guide
Research direction
Start with the System.Drawing.Bitmap-to-MagickImage conversion path and compare it with loading the attached Test.jpg directly through Magick.NET. Inspect GetExifProfile().GetValue(ExifTag.ImageHistory) and the resulting ExifIfd assignment. Done means both loading paths preserve the ImageHistory value under the expected Exif IFD.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100