Skip to content

Incorrect ExifIfds for ImageHistory exif tag (or conversion issue from System.Drawing.Bitmap) #2042

Description

@JPDelprat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions