Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3 : Fix GIF, PNG, and WEBP Edge Case Handling #2882

Open
wants to merge 17 commits into
base: release/3.1.x
Choose a base branch
from

Conversation

JimBobSquarePants
Copy link
Member

@JimBobSquarePants JimBobSquarePants commented Feb 7, 2025

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

Fixes #2866
Fixes #2862

There's quite a lot going on here:

  • Both GIF and WEBP decoders were not handling frame disposal properly.
  • GIF Decoder background color handling was incorrect.
  • GIF Encoder incorrectly used global palette for local root frame.
  • WEBP Decoder did not clear some buffers on load where it should.
  • PNG Encoder palette animations did not work properly
  • Fixed pixel sampling in Wu and Octree quantizers
  • Improved accuracy for matching first 512 colors in EuclidianPixelMap.

I'll have to manually rework this for V4 as the code base has migrated significantly there.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 16 changed files in this pull request and generated no comments.

Files not reviewed (11)
  • tests/Images/External/ReferenceOutput/GifDecoderTests/Issue1962_Rgba32_issue1962_tiniest_gif_1st.png: Language not supported
  • tests/Images/External/ReferenceOutput/GifDecoderTests/Issue2012BadMinCode_Rgba32_issue2012_drona1.png: Language not supported
  • tests/Images/Input/Gif/issues/issue_2866.gif: Language not supported
  • tests/Images/Input/Webp/issues/Issue2866.webp: Language not supported
  • src/ImageSharp/Formats/Gif/GifEncoderCore.cs: Evaluated as low risk
  • tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/MagickReferenceDecoder.cs: Evaluated as low risk
  • src/ImageSharp/Formats/Webp/Lossy/Vp8Decoder.cs: Evaluated as low risk
  • src/ImageSharp/Formats/Webp/BitReader/BitReaderBase.cs: Evaluated as low risk
  • tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs: Evaluated as low risk
  • tests/ImageSharp.Tests/TestImages.cs: Evaluated as low risk
  • src/ImageSharp/Formats/Webp/WebpBlendMethod.cs: Evaluated as low risk
Comments suppressed due to low confidence (2)

tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs:389

  • [nitpick] The test method name GifEncoder_CanDecode_Issue2866 is misleading since it is testing encoding, not decoding. It should be renamed to GifEncoder_CanEncode_Issue2866.
public void GifEncoder_CanDecode_Issue2866<TPixel>(TestImageProvider<TPixel> provider)

src/ImageSharp/Formats/Webp/WebpAnimationDecoder.cs:89

  • The comment should reflect the correct type for backgroundColor, which is TPixel instead of Color.
/// <param name="backgroundColor">The default background color of the canvas in.</param>
@JimBobSquarePants JimBobSquarePants changed the title V3 : Fix GIF and WEBP Edge Case Handling V3 : Fix GIF, PNG, and WEBP Edge Case Handling Feb 25, 2025
@antonfirsov
Copy link
Member

This is quite a huge change, but I'm planning to take a high-level look in the coming days.

@JimBobSquarePants
Copy link
Member Author

This is quite a huge change, but I'm planning to take a high-level look in the coming days.

Thanks! I have a V4 version also that I’m going to push, lots of similarities but also some additional changes.

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.

2 participants