From c86a3fad3e2fb01d6905cf339a876159aac57280 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 14 May 2016 18:55:23 +1000 Subject: [PATCH] Save as Png should accept quality parameter. Former-commit-id: 61d66fea55c703113aa99a1c9f6619a21c0dae78 Former-commit-id: caa452215871358f1d154b890ab04b1730535964 Former-commit-id: 2b75e0496c82ceeedc7c8fab1734cf464ad86c21 --- src/ImageProcessorCore/ImageExtensions.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ImageProcessorCore/ImageExtensions.cs b/src/ImageProcessorCore/ImageExtensions.cs index 597c681df2..025c739b97 100644 --- a/src/ImageProcessorCore/ImageExtensions.cs +++ b/src/ImageProcessorCore/ImageExtensions.cs @@ -30,8 +30,11 @@ namespace ImageProcessorCore /// /// The image this method extends. /// The stream to save the image to. + /// The quality to save the image to representing the number of colors. + /// Anything equal to 256 and below will cause the encoder to save the image in an indexed format. + /// /// Thrown if the stream is null. - public static void SaveAsPng(this ImageBase source, Stream stream) => new PngEncoder().Encode(source, stream); + public static void SaveAsPng(this ImageBase source, Stream stream, int quality = int.MaxValue) => new PngEncoder { Quality = quality }.Encode(source, stream); /// /// Saves the image to the given stream with the jpeg format. @@ -47,7 +50,7 @@ namespace ImageProcessorCore /// /// The image this method extends. /// The stream to save the image to. - /// The quality to save the image to representing the number of colors. Between 1 and 100. + /// The quality to save the image to representing the number of colors. Between 1 and 256. /// Thrown if the stream is null. public static void SaveAsGif(this ImageBase source, Stream stream, int quality = 256) => new GifEncoder { Quality = quality }.Encode(source, stream);