Skip to content

When loading a tiff with an icc profile using ColorProfileHandling.Preserve the ICC Profile is lost #3145

@Socolin

Description

@Socolin

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 and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

4.0.0

Other ImageSharp packages and versions

NA

Environment (Operating system, version and so on)

Ubuntu 24.04

.NET Framework version

net10

Description

Hello,

When loading a .tiff with an icc profile and the option ColorProfileHandling.Preserve the profile is not applied (as expected) but the field Metadata.IccProfile is null so the info about the profile is lost.

If I encode the image as JPEG afterward, the profile not saved in the file.

Steps to Reproduce

Console.WriteLine("Preserve:");
using var imgPreserve = Image.Load(new DecoderOptions
   {
   	ColorProfileHandling = ColorProfileHandling.Preserve,
   },
   "tiff_test_image_with_icc_profile.tiff"
);
Console.WriteLine("  IccProfile: " + (imgPreserve.Metadata.IccProfile?.ToString() ?? "null"));
imgPreserve.Save("image.icc.preserverd.jpg");
Console.WriteLine("  File: " + Path.Combine("file: " + Path.GetFullPath("image.icc.preserverd.jpg")));

Console.WriteLine("Convert:");
using var imgConvert = Image.Load(new DecoderOptions
   {
   	ColorProfileHandling = ColorProfileHandling.Convert,
   },
   "tiff_test_image_with_icc_profile.tiff"
);
Console.WriteLine("  IccProfile: " + (imgConvert.Metadata.IccProfile?.ToString() ?? "null"));
imgConvert.Save("image.icc.converted.jpg");
Console.WriteLine("  File: " + Path.Combine("file: " + Path.GetFullPath("image.icc.converted.jpg")));

Images

The tiff:

tiff_test_image_with_icc_profile.tiff

image.icc.converted.jpg: (Correct)
Image

image.icc.preserverd.jpg: (Invalid)
Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions