From a9a4f6f51d32682543a671914c70553b82e38b09 Mon Sep 17 00:00:00 2001 From: Dmitry Pentin Date: Thu, 22 Jul 2021 05:59:53 +0300 Subject: [PATCH] Removed luma/chroma quality from the encoder --- .../Formats/Jpeg/IJpegEncoderOptions.cs | 15 ++----- src/ImageSharp/Formats/Jpeg/JpegEncoder.cs | 40 +------------------ .../Formats/Jpeg/JpegEncoderCore.cs | 4 +- 3 files changed, 8 insertions(+), 51 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs b/src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs index d2921ad4c0..a9f564b450 100644 --- a/src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs +++ b/src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs @@ -9,18 +9,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg internal interface IJpegEncoderOptions { /// - /// 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 75. /// - /// The quality of the jpg image from 0 to 100. - int? LuminanceQuality { get; } - - /// - /// 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). - /// - /// The quality of the jpg image from 0 to 100. - int? ChrominanceQuality { get; } + public int? Quality { get; set; } /// /// Gets the subsample ration, that will be used to encode the image. diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs index 27597a0f99..5e199b4204 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs +++ b/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 /// public sealed class JpegEncoder : IImageEncoder, IJpegEncoderOptions { - /// - /// 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 75. - /// - 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; - } - } - - /// - /// 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 75. - /// - public int? LuminanceQuality { get; set; } - - /// - /// 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 75. - /// - public int? ChrominanceQuality { get; set; } + /// + public int? Quality { get; set; } /// /// Gets or sets the subsample ration, that will be used to encode the image. diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs index 9c66cfe0c3..248772b287 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs @@ -64,8 +64,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// The options 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; }