Skip to content

Saving TIFF file is causing IccProfile and IptcProfile on existing file to be set to NULL #2504

@JeffP134

Description

@JeffP134

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

3.0.1

Other ImageSharp packages and versions

None

Environment (Operating system, version and so on)

Windows 10

.NET Framework version

.NET 6

Description

I am using Visual Studio 2022 and .NET 6 to build an image metadata editor so I can edit multiple related image files at the same time.

I am able to load and edit both JPEG and TIFF metadata tags just fine on the ExifProfile sections of each format, and IptcProfile changes appear to be working prior to saving to disk.

However, upon saving back to the original file, the existing IccProfile and IptcProfile structures are being set to NULL in the image, resulting in a loss of information. ExifProfile and XmpProfile appear to be fine after the save, but I haven't inspected the XmpProfile closely to be sure.

This is also reducing the TIFF file size from 77 MB to 15 MB.

I was expecting the save to retain the IccProfile as is, and for the IptcProfile to be updated with my changes.

The following screenshots illustrate the issue.

TIFF Profiles before Editing ExifProfile and IptcProfile
TIFF Profiles Pre Edit
TIFF Profiles after Editing but Before File Save
TIFF Profiles Post Edit
TIFF Profiles after Saving to Disk
TIFF Profiles After Save

File Size Pre-Edit
File Size Pre-Edit
File Size After Save
File Size Post-Edit

Steps to Reproduce

  1. Using ImageSharp's Image class, open a TIFF image file that has the IccProfile and IptcProfile properties of the RootFrame filled in at Image.Frames.RootFrame.Metadata
  2. Edit the ExifProfile and IptcProfile sections of Image.Frames.RootFrame.Metadata to update metadata tags
  3. Save the TIFF image to the hard drive
  4. Open the saved TIFF image and check the IccProfile and IptcProfile properties of Image.Frames.RootFrame.Metadata

Images

The attached file is a smaller TIFF that only has the ExifProfile, IccProfile, and XmpProfile sections populated. In this scenario, my code creates and then populates the IptcProfile prior to saving.

But after the save, the file size reduces from 10 MB to 2 MB, and IccProfile and IptcProfile are both null.
Sunspot Region 3354 Colorized 2023-07-02 13-55.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions