mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.2 KiB
56 lines
2.2 KiB
// <copyright file="JpegEncoderOptions.cs" company="James Jackson-South">
|
|
// Copyright (c) James Jackson-South and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
|
|
namespace ImageSharp.Formats
|
|
{
|
|
/// <summary>
|
|
/// Encapsulates the options for the <see cref="JpegEncoder"/>.
|
|
/// </summary>
|
|
public sealed class JpegEncoderOptions : EncoderOptions, IJpegEncoderOptions
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="JpegEncoderOptions"/> class.
|
|
/// </summary>
|
|
public JpegEncoderOptions()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="JpegEncoderOptions"/> class.
|
|
/// </summary>
|
|
/// <param name="options">The options for the encoder.</param>
|
|
private JpegEncoderOptions(IEncoderOptions options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
/// <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).
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// If the quality is less than or equal to 90, the subsampling ratio will switch to <see cref="JpegSubsample.Ratio420"/>
|
|
/// </remarks>
|
|
/// <value>The quality of the jpg image from 0 to 100.</value>
|
|
public int Quality { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the subsample ration, that will be used to encode the image.
|
|
/// </summary>
|
|
/// <value>The subsample ratio of the jpg image.</value>
|
|
public JpegSubsample? Subsample { get; set; }
|
|
|
|
/// <summary>
|
|
/// Converts the options to a <see cref="IJpegEncoderOptions"/> instance with a
|
|
/// cast or by creating a new instance with the specfied options.
|
|
/// </summary>
|
|
/// <param name="options">The options for the encoder.</param>
|
|
/// <returns>The options for the <see cref="JpegEncoder"/>.</returns>
|
|
internal static IJpegEncoderOptions Create(IEncoderOptions options)
|
|
{
|
|
return options as IJpegEncoderOptions ?? new JpegEncoderOptions(options);
|
|
}
|
|
}
|
|
}
|
|
|