aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Drawing/ImageHelper.cs
blob: 6f26b7d912d476dadae436454099bf6e7cb340ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma warning disable CS1591

using MediaBrowser.Model.Drawing;

namespace MediaBrowser.Controller.Drawing
{
    public static class ImageHelper
    {
        public static ImageDimensions GetNewImageSize(ImageProcessingOptions options, ImageDimensions originalImageSize)
        {
            // Determine the output size based on incoming parameters
            var newSize = DrawingUtils.Resize(originalImageSize, options.Width ?? 0, options.Height ?? 0, options.MaxWidth ?? 0, options.MaxHeight ?? 0);
            newSize = DrawingUtils.ResizeFill(newSize, options.FillWidth, options.FillHeight);

            // Never encode larger than the source.
            return DrawingUtils.ScaleDownToFit(newSize, originalImageSize);
        }
    }
}