Commit Graph

21 Commits

Author SHA1 Message Date
Cody Robibero 82ecfde2f7 Update MediaBrowser.Controller/Drawing/ImageHelper.cs
Co-authored-by: Tim Eisele <Tim_Eisele@web.de>
2026-08-10 16:10:08 -04:00
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 383c2d7374 Remove useless nullable directives 2021-06-11 23:36:10 +02:00
Bond_009 fb090df0b5 Enable nullable reference types for MediaBrowser.Controller 2021-05-07 00:39:20 +02:00
BaronGreenback bc1cc2d04a Remove unused using directives 2021-04-17 11:37:55 +01:00
Odd Stråbø e57c1655fb Remove GetSizeEstimate & GetEstimatedAspectRatio
from MediaBrowser.Controller.Drawing.ImageHelper

Rework GetCacheFilePath to take requested with and height parameters
in stead of using estimated output size
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 404bb4f835 Enable TreatWarningsAsErrors for MediaBrowser.Controller in Release 2020-08-22 21:56:24 +02:00
telans 247f9c61e6 fix SA1513/SA1516 2020-06-16 16:11:30 +12:00
Patrick Barron 7d9d54d2ec Fix profile images. 2020-05-20 12:09:52 -04:00
Bond_009 ddf9b38799 Simplify image processing by removing image enhancers 2020-01-21 20:26:30 +01:00
Claus Vium dc68d61491 Fix default aspect ratio 2019-01-28 21:55:44 +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 ba610b5094 Find+Sed BOM removal *.cs: Jellyfin.Server-MediaBrowser.Controller 2019-01-13 21:01:16 +01:00
Erwin de Haan 26ca4b607b Visual Studio Reformat: MediaBrowser.Controller 2019-01-13 20:25:32 +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 31b01cbb56 add fixes for dng images 2017-09-22 16:33:01 -04:00
Luke Pulverenti 52aeb3c40b consolidate interfaces 2017-08-07 17:06:13 -04:00
Luke Pulverenti 9cd2d793be update image encoding 2017-05-17 14:18:18 -04:00
Luke Pulverenti 2f4f8c105e update image processing 2017-05-14 22:27:58 -04:00