Add ICC profile conversion support to WEBP#3051
Merged
JimBobSquarePants merged 3 commits intomainfrom Jan 28, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds ICC profile conversion support to the WebP decoder and introduces AVX2/AVX‑512 SIMD optimizations for RGB/color-profile conversions, plus tests and assets to validate the new behavior.
Changes:
- Extends
WebpDecoderCoreto run ICC profile conversion viaTryConvertIccProfileafter decoding single-frame images. - Adds WebP ICC-profile test images and reference PNG outputs, and new WebP decoder tests that validate ICC conversion/removal when
ColorProfileHandling.Convertis used. - Optimizes
Rgb.ToScaledVector4/Rgb.FromScaledVector4andColorProfileConverterExtensionsPixelCompatible.Convertwith AVX2/AVX‑512 paths to accelerate RGB vectorization and profile conversion while preserving alpha.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Images/Input/Webp/icc-profiles/Perceptual.webp | New WebP test asset with perceptual ICC profile for WebP ICC conversion tests (LFS pointer). |
| tests/Images/Input/Webp/icc-profiles/Perceptual-cLUT-only.webp | New WebP test asset with perceptual cLUT-only ICC profile for ICC conversion tests (LFS pointer). |
| tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual.png | Reference PNG output for WebP perceptual ICC profile conversion test (LFS pointer). |
| tests/Images/External/ReferenceOutput/WebpDecoderTests/Decode_WhenColorProfileHandlingIsConvert_ApplyIccProfile_Rgba32_Perceptual-cLUT-only.png | Reference PNG output for WebP perceptual cLUT-only ICC profile conversion test (LFS pointer). |
| tests/ImageSharp.Tests/TestImages.cs | Adds Lossy.Icc WebP paths (Perceptual, PerceptualcLUTOnly) so tests can reference the new ICC WebP assets. |
| tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs | Adds ICC conversion test for WebP using the new ICC WebP images and reference PNGs, plus (unused) PNG using directive. |
| tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs | Imports WebP namespace (currently unused) in PNG decoder tests while leaving existing ICC tests unchanged. |
| src/ImageSharp/Formats/Webp/WebpDecoderCore.cs | Calls TryConvertIccProfile(image) after parsing optional chunks to align WebP ICC handling with other decoders. |
| src/ImageSharp/ColorProfiles/Rgb.cs | Replaces scalar loops in ToScaledVector4/FromScaledVector4 with AVX2/AVX‑512 SIMD implementations and adds helper read/write intrinsics. |
| src/ImageSharp/ColorProfiles/ColorProfileConverterExtensionsPixelCompatible.cs | Optimizes pixel-compatible ICC conversion path with AVX2/AVX‑512 to merge converted RGB back into Vector4 rows while preserving alpha. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
This pull request adds support for ICC color profile conversion in the WebP decoder and corresponding tests and test images to validate this behavior. It also introduces significant SIMD optimizations for color profile conversions in the
Rgbstruct and related code, leveraging AVX2 and AVX-512 intrinsics for much faster pixel processing.WebP Decoder: ICC Profile Conversion Support
WebpDecoderCoreto attempt ICC profile conversion when decoding images, aligning its behavior with other decoders whenColorProfileHandling.Convertis set.Testing: New Test Cases and Assets
WebpDecoderTeststo verify that ICC profiles are correctly converted and removed from metadata whenColorProfileHandling.Convertis used. [1] [2]SIMD Optimizations for Color Conversion
Rgb.ToScaledVector4,Rgb.FromScaledVector4, and the color profile conversion inColorProfileConverterExtensionsPixelCompatible, resulting in much faster color conversion by processing multiple pixels in parallel. Helper methods for reading/writing SIMD vectors were also added. [1] [2] [3] [4] [5]