Browse Source

Save as Png should accept quality parameter.

Former-commit-id: 61d66fea55c703113aa99a1c9f6619a21c0dae78
Former-commit-id: caa452215871358f1d154b890ab04b1730535964
Former-commit-id: 2b75e0496c82ceeedc7c8fab1734cf464ad86c21
pull/1/head
James Jackson-South 10 years ago
parent
commit
c86a3fad3e
  1. 7
      src/ImageProcessorCore/ImageExtensions.cs

7
src/ImageProcessorCore/ImageExtensions.cs

@ -30,8 +30,11 @@ namespace ImageProcessorCore
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="quality">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.
/// </param>
/// <exception cref="ArgumentNullException">Thrown if the stream is null.</exception>
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);
/// <summary>
/// Saves the image to the given stream with the jpeg format.
@ -47,7 +50,7 @@ namespace ImageProcessorCore
/// </summary>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="quality">The quality to save the image to representing the number of colors. Between 1 and 100.</param>
/// <param name="quality">The quality to save the image to representing the number of colors. Between 1 and 256.</param>
/// <exception cref="ArgumentNullException">Thrown if the stream is null.</exception>
public static void SaveAsGif(this ImageBase source, Stream stream, int quality = 256) => new GifEncoder { Quality = quality }.Encode(source, stream);

Loading…
Cancel
Save