Skip to content

Saving JPEG Quality defaults to below 5 - ignoring default of 75 #845

@Marcel0024

Description

@Marcel0024

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

Saving certain Jpeg images without defining the JpegEnconder quality defaults to a quality below 5.
There's a few jpeg I've seem with this behavior, can't pin point an common trait. Examples further below.

Steps to Reproduce

using (var img = Image.Load("original.jpg"))
{
    using (FileStream outImage = File.Create("result.jpg"))
    {
        img.SaveAsJpeg(outImage);
    }
}

Results:

image

With Quality at 50:

using (var img = Image.Load("original.jpg"))
{
    using (FileStream outImage = File.Create("result.jpg"))
    {
        img.SaveAsJpeg(outImage, new JpegEncoder { Quality = 50 } );
    }
}

Results:

image

As you can see quality 50 produces a higher quality image.
Here are 3 examples images:
quality-loss-example.zip

I've managed to track it down to SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.QualityEvaluator#EstimateQuality method.
'Normal' jpeg this method returns a 75 default quality. My example images the method returns 3 or 2.
image

System Configuration

  • ImageSharp version: 1.0.0-beta0006
  • Environment (Operating system, version and so on): Windows 10 pro -Windows Server 2016
  • .NET Framework version: .Net Core 2.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions