Browse Source

Removed luma/chroma quality from the encoder

pull/1706/head
Dmitry Pentin 5 years ago
parent
commit
a9a4f6f51d
  1. 15
      src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs
  2. 40
      src/ImageSharp/Formats/Jpeg/JpegEncoder.cs
  3. 4
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

15
src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs

@ -9,18 +9,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
internal interface IJpegEncoderOptions
{
/// <summary>
/// Gets the quality, that will be used to encode the luminance data of the image.
/// Quality index must be between 0 and 100 (compression from max to min).
/// Gets or sets the quality, that will be used to encode the image. Quality
/// index must be between 0 and 100 (compression from max to min).
/// Defaults to <value>75</value>.
/// </summary>
/// <value>The quality of the jpg image from 0 to 100.</value>
int? LuminanceQuality { get; }
/// <summary>
/// Gets the quality, that will be used to encode the chrominance data of the image.
/// Quality index must be between 0 and 100 (compression from max to min).
/// </summary>
/// <value>The quality of the jpg image from 0 to 100.</value>
int? ChrominanceQuality { get; }
public int? Quality { get; set; }
/// <summary>
/// Gets the subsample ration, that will be used to encode the image.

40
src/ImageSharp/Formats/Jpeg/JpegEncoder.cs

@ -1,7 +1,6 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -14,43 +13,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// </summary>
public sealed class JpegEncoder : IImageEncoder, IJpegEncoderOptions
{
/// <summary>
/// Gets or sets the quality, that will be used to encode the image. Quality
/// index must be between 0 and 100 (compression from max to min).
/// Defaults to <value>75</value>.
/// </summary>
public int? Quality
{
[Obsolete("This accessor will soon be deprecated. Use LuminanceQuality and ChrominanceQuality getters instead.", error: false)]
get
{
const int defaultQuality = 75;
int lumaQuality = this.LuminanceQuality ?? defaultQuality;
int chromaQuality = this.LuminanceQuality ?? lumaQuality;
return (int)Math.Round((lumaQuality + chromaQuality) / 2f);
}
set
{
this.LuminanceQuality = value;
this.ChrominanceQuality = value;
}
}
/// <summary>
/// Gets or sets the quality, that will be used to encode luminance image data.
/// Quality index must be between 0 and 100 (compression from max to min).
/// Defaults to <value>75</value>.
/// </summary>
public int? LuminanceQuality { get; set; }
/// <summary>
/// Gets or sets the quality, that will be used to encode chrominance image data.
/// Quality index must be between 0 and 100 (compression from max to min).
/// Defaults to <value>75</value>.
/// </summary>
public int? ChrominanceQuality { get; set; }
/// <inheritdoc/>
public int? Quality { get; set; }
/// <summary>
/// Gets or sets the subsample ration, that will be used to encode the image.

4
src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

@ -64,8 +64,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <param name="options">The options</param>
public JpegEncoderCore(IJpegEncoderOptions options)
{
this.luminanceQuality = options.LuminanceQuality;
this.chrominanceQuality = options.ChrominanceQuality;
this.luminanceQuality = options.Quality;
this.chrominanceQuality = options.Quality;
this.subsample = options.Subsample;
this.colorType = options.ColorType;
}

Loading…
Cancel
Save