Skip to content

Add ImageInfo.GetPixelMemorySize; docs & tests#3108

Merged
JimBobSquarePants merged 1 commit intomainfrom
js/imageinfobytes
Apr 7, 2026
Merged

Add ImageInfo.GetPixelMemorySize; docs & tests#3108
JimBobSquarePants merged 1 commit intomainfrom
js/imageinfobytes

Conversation

@JimBobSquarePants
Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

This pull request enhances the ImageInfo class in ImageSharp by improving documentation and adding a new method to calculate the in-memory pixel size of an image, along with corresponding unit tests. The changes clarify the meaning and usage of frame metadata and ensure accurate reporting of memory requirements for both single-frame and multi-frame images.

Enhancements to ImageInfo API and documentation:

  • Added the GetPixelMemorySize() method to ImageInfo, which computes the total number of bytes required to store the image's pixel data in memory, taking into account the number of frames when available.
  • Improved XML documentation for the FrameCount and FrameMetadataCollection properties to clarify their behavior, especially regarding multi-frame and single-frame formats. [1] [2]

Testing improvements:

  • Added unit tests in ImageInfoTests to verify that GetPixelMemorySize() returns the correct value for both single-frame images and images with multiple frame metadata entries.

Minor code cleanup:

  • Removed unnecessary null-forgiving operator in GifDecoderCore when assigning rawColorTable.

@JimBobSquarePants JimBobSquarePants merged commit 66f21f7 into main Apr 7, 2026
12 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/imageinfobytes branch April 7, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant