Skip to content

Vectorized 4:2:0 subsampling leads to artifacts during Jpeg encoding.  #1549

Closed

Description

@JimBobSquarePants

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

Description

Issue originally identified by @jrdiver in #1547 Thanks for that!

The new vectorized subsampling algorithm introduced in #1517 by @tkp1n is creating artifacts in our jpeg output. Unfortunately our regression tests did not capture the issue.

v1.0.3-alpha.0.28

fb

v1.0.3-alpha.0.29

fb - Copy

Steps to Reproduce

Simply resaving the input image is enough ensuring the quality is low enough to trigger 4:2:0 subsampling.

using (var image = Image.Load(Path.Combine(inPath, "fb.jpg")))
{
    image.Save(Path.Combine(outPath, "fb.jpg"), new JpegEncoder { Quality = 75 });
}

System Configuration

  • ImageSharp version: v1.0.3-alpha.0.29
  • Other ImageSharp packages and versions: NA
  • Environment (Operating system, version and so on): All
  • .NET Framework version: NET Core 3.1+
  • Additional information:

Activity

  1. added this to the milestone on Feb 13, 2021
  2. antonfirsov commented on Feb 13, 2021

    @antonfirsov
    Member

    I'm not sure quality matters here. This is the output EncodeBaseline_WorksWithDifferentSizes_Rgba32_TestPattern600x400_Ratio420-Q100.jpeg which should run with Quality=100 if everything is correct:

    image

  3. JimBobSquarePants commented on Feb 13, 2021

    @JimBobSquarePants
    MemberAuthor

    Quality just triggers the subsampling when < 91 so yes, explicitly setting the property would be enough.

  4. antonfirsov commented on Feb 13, 2021

    @antonfirsov
    Member

    This should have been caught by our tests. Opened #1550.

    @tkp1n any chance you can take a look?

  5. tkp1n commented on Feb 14, 2021

    @tkp1n
    Contributor

    I found the issue.. expect a PR coming soon

  6. linked a pull request that will close this issueFix vectorized 4:2:0 subsampling #1551on Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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