Commit Graph

17 Commits

Author SHA1 Message Date
vavallee e120b7f2dd Stop image endpoints from upscaling beyond the source resolution
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.
2026-08-07 12:33:37 -03:00
Bond_009 c7d50d640e Replace == null with is null 2022-12-05 15:00:20 +01:00
Odd Stråbø afff226514 Apply suggestions from code review
Co-authored-by: Cody Robibero <cody@robibe.ro>
2021-04-11 08:21:23 +02:00
Odd Stråbø 13d0837b78 (mostly)Fix ResizeFill 2021-04-11 08:21:23 +02:00
Odd Stråbø 383aa4e4d9 Add Resize to fill box alternative to image endpoints 2021-04-11 08:20:47 +02:00
Bond_009 30ce346f34 Enable nullabe reference types for MediaBrowser.Model 2020-04-05 18:10:56 +02:00
Bond_009 f47ad85011 Fix warnings MediaBrowser.Model 2020-02-04 01:49:27 +01:00
Bond_009 883575893b Change image dimentions from double to int
Rename ImageSize -> ImageDimensions
2019-01-26 13:16:47 +01:00
Erwin de Haan 8f41ba4d3a Find+Sed BOM removal *.cs: MediaBrowser.LocalMetadata-MediaBrowser.Model 2019-01-13 21:02:23 +01:00
Andrew Rabert a86b71899e Add GPL modules 2018-12-27 18:27:57 -05:00
stefan 48facb797e Update to 3.5.2 and .net core 2.1 2018-09-12 19:26:21 +02:00
Luke Pulverenti e653b41000 removed implicit typing from the model project 2014-05-08 16:44:17 -04:00
Luke Pulverenti bb031f553b fix portable and 3.5 project references 2014-05-08 16:26:20 -04:00
Luke Pulverenti f02c326027 Removed guids from the model project 2014-05-08 16:09:53 -04:00
Luke Pulverenti 2fc662c9e9 optimize image processor when gdi can be skipped 2013-11-07 10:57:12 -05:00
Luke Pulverenti a2cd03610f Serve original image file when possible 2013-11-06 16:32:26 -05:00
LukePulverenti 767cdc1f6f Pushing missing changes 2013-02-20 20:33:05 -05:00