aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Drawing/DrawingUtils.cs
AgeCommit message (Collapse)Author
5 daysStop image endpoints from upscaling beyond the source resolutionvavallee
ImageHelper.GetNewImageSize passed the caller-supplied width/height straight through to SkiaEncoder.EncodeImage, which allocates an SKImageInfo of exactly that size. Nothing bounded those values against the source image, so a request like Items/<id>/Images/Primary?width=23100&height=23100 made the server allocate and resample a 23100x23100 surface from, say, a 600x336 poster: the reporter measured 100% of a core for 10-15 minutes and 6-12 GB resident per request. The item images endpoints do not require authentication, so any caller who knows an item id can trigger this, and varying the size by one pixel misses the cache every time. Add DrawingUtils.ScaleDownToFit, which scales a size down uniformly until it fits inside a bounding box and returns it unchanged if it already does, and apply it in GetNewImageSize against the original image dimensions. Requests that ask for more pixels than the source now get the source resolution back, scaled to the requested aspect ratio. Downscaling paths are untouched, and DrawingUtils.Resize keeps its existing behaviour for the transcoding callers in EncodingJobInfo and StreamInfo, which legitimately size video output. ResizeFill already refused to upscale; this makes width/height consistent with fillWidth/fillHeight. Fixes #17056.
2022-12-05Replace == null with is nullBond_009
2021-04-11Apply suggestions from code reviewOdd Stråbø
Co-authored-by: Cody Robibero <cody@robibe.ro>
2021-04-11(mostly)Fix ResizeFillOdd Stråbø
2021-04-11Add Resize to fill box alternative to image endpointsOdd Stråbø
2020-04-05Enable nullabe reference types for MediaBrowser.ModelBond_009
2020-02-04Fix warnings MediaBrowser.ModelBond_009
2019-01-26Change image dimentions from double to intBond_009
Rename ImageSize -> ImageDimensions
2019-01-13Find+Sed BOM removal *.cs: MediaBrowser.LocalMetadata-MediaBrowser.ModelErwin de Haan
2018-12-27Add GPL modulesAndrew Rabert
2018-09-12Update to 3.5.2 and .net core 2.1stefan
2014-05-08removed implicit typing from the model projectLuke Pulverenti
2014-05-08fix portable and 3.5 project referencesLuke Pulverenti
2014-05-08Removed guids from the model projectLuke Pulverenti
2013-11-07optimize image processor when gdi can be skippedLuke Pulverenti
2013-11-06Serve original image file when possibleLuke Pulverenti
2013-02-20Pushing missing changesLukePulverenti