[backend/drive] Fix missing image processing resolution check

This commit is contained in:
Laura Hausmann 2024-08-08 18:15:07 +02:00
parent 7b3e9bbbca
commit f903a1d8a4
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 11 additions and 2 deletions

View file

@ -209,6 +209,8 @@ public sealed class Config
[Range(0, 128)] public int ImageProcessorConcurrency { get; init; } = 8; [Range(0, 128)] public int ImageProcessorConcurrency { get; init; } = 8;
public int MaxResolutionPx => MaxResolutionMpx * 1000 * 1000;
public string MaxFileSize public string MaxFileSize
{ {
get => MaxFileSizeBytes.ToString(); get => MaxFileSizeBytes.ToString();

View file

@ -261,8 +261,16 @@ public class DriveService(
logger.LogDebug("Image is animated, bypassing image processing..."); logger.LogDebug("Image is animated, bypassing image processing...");
skipImageProcessing = true; skipImageProcessing = true;
} }
else if (ident.Width * ident.Height > storageConfig.Value.MediaProcessing.MaxResolutionPx)
{
logger.LogDebug("Image is larger than {mpx}mpx ({width}x{height}), bypassing image processing...",
storageConfig.Value.MediaProcessing.MaxResolutionMpx, ident.Width,
ident.Height);
skipImageProcessing = true;
}
var formats = GetFormats(user, request, skipImageProcessing); var formats = GetFormats(user, request, skipImageProcessing);
var res = imageProcessor.ProcessImage(buf, ident, request, formats); var res = imageProcessor.ProcessImage(buf, ident, request, formats);
properties = res; properties = res;
blurhash = res.Blurhash; blurhash = res.Blurhash;

View file

@ -1,5 +1,4 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security;
using CommunityToolkit.HighPerformance; using CommunityToolkit.HighPerformance;
using Iceshrimp.Backend.Core.Helpers; using Iceshrimp.Backend.Core.Helpers;
using NetVips; using NetVips;