SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.26k stars 844 forks source link

Add API for metadata conversion between formats. #2751

Open JimBobSquarePants opened 4 weeks ago

JimBobSquarePants commented 4 weeks ago

Prerequisites

Description

This is one of those monster PRs that everyone hates but since it touches all image formats was unavoidable.

This PR stems from the v4 roadmap discussion here.

It does three things.

  1. Builds upon and replaces the work done in #2588 to allow conversion between animated image formats. This allows accurate conversion between all image formats.
  2. Exposes rich metadata with PixelTypeInfo that describes the pixel format of the encoded image.
  3. Normalizes the synchronization of profile (EXIF) metadata upon save.

Two bridging metadata types FormatConnectingMetadata and FormatFrameConnectingMetadata have been introduced along with interfaces IFormatMetadata, IFormatMetadata<TSelf>, IFormatFrameMetadata, IFormatFrameMetadata<TSelf> which enforce conversion APIs between all our format metadata types.

Naming conventions, type usage, and behavior has also been normalized across all our metadata types.

PixelColorType has been expanded to allow for exotic types not used in our own pixel formats and is now present alongside PixelComponentInfo and PixelAlphaRepresentation in the PixelTypeInfo instance returned with ImageInfo.