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

Created on 13 Feb 2021  路  4Comments  路  Source: SixLabors/ImageSharp

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have verified that I am running the latest version of ImageSharp
  • [x] I have verified if the problem exist in both DEBUG and RELEASE mode
  • [x] 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.

c# 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:
bug jpeg

Most helpful comment

I found the issue.. expect a PR coming soon

All 4 comments

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

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

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

@tkp1n any chance you can take a look?

I found the issue.. expect a PR coming soon

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JimBobSquarePants picture JimBobSquarePants  路  3Comments

vad3x picture vad3x  路  4Comments

vpenades picture vpenades  路  4Comments

devedse picture devedse  路  3Comments

jarroda picture jarroda  路  3Comments