Magick.NET
Magick.NET copied to clipboard
Update to 14.4.0: Error MagickImageErrorException: width or height exceeds limit, when using MagickImage Rotate
Magick.NET version
14.4.0
Environment (Operating system, version and so on)
Windows Server 2022, ASP.NET 9.0, C#
Description
I changed from 14.2.0 to 14.5.0. Now I receive:
ImageMagick.MagickImageErrorException: width or height exceeds limit "Schutzvermerk Sammlung JORE" (33554431x33554431) @ error/cache.c/OpenPixelCache/3692
at ImageMagick.MagickExceptionHelper.Check(IntPtr exception) in /_/src/Magick.NET/Exceptions/MagickExceptionHelper.cs:line 18
at ImageMagick.NativeHelper.CheckException(IntPtr exception) in /_/src/Magick.NET/Native/NativeHelper.cs:line 20
at ImageMagick.MagickImage.NativeMagickImage.Rotate(Double degrees) in /_/src/Magick.NET/Generated/Magick.NET.SourceGenerator/ImageMagick.SourceGenerator.NativeInteropGenerator/MagickImage.g.cs:line 6167
at ImageMagick.MagickImage.CloneMutator.Rotate(Double degrees) in /_/src/Magick.NET/MagickImage.CloneMutator.cs:line 467
at ImageMagick.MagickImage.Rotate(Double degrees) in /_/src/Magick.NET/MagickImage.cs:line 5487
at Sammler_Homepage.Controllers.SettingsController.PicturesUploading(String WatermarkText, List1 postedFiles, String returnUrl) in C:\Users\User\Documents\repos\sammler-homepage\Controllers\SettingsController.cs:line 131
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Sammler_Homepage.Startup.<>c__DisplayClass5_0.<<Configure>b__0>d.MoveNext() in C:\Users\User\Documents\repos\sammler-homepage\Startup.cs:line 65
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.ResponseCaching.ResponseCachingMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
It only occurs on my server, not when I test it on my PC. It happens when I use Magick Image Rotate in my Code.
Steps to Reproduce
IT occurs when I run it on Webhosting, not PC.
Code:
public ActionResult UploadingTest()
{
MagickImage watermark = new($"label:{"Testtext"}");
watermark.Rotate(315);
return Ok();
}
After removing watermark.Rotate(); It doesn't occure anymore.
I can also not reproduce it on my machine. The message your are getting suggests that you have configured ResourceLimits on your server. Did you check your code to make sure you are not setting this anywhere?
Can you upgrade to 14.5.0? This should provide you with a better error message.
I updated to 14.5.0, still the same. I contact my Hosting-Provider, if he could get me information about the environment.
The error message should contain a bit more information? It should print the limits in the error message. Maybe you can use that number to search through your software?
I added the raw exception details unfortunatelly now the code snippet is not so easy to read anymore. Sorry
Thanks for updating the issue and I have edited it to make it more readable you will need to use three `'s to make it work multiline. You are hitting a limit that is 33554431x33554431 but that seems very strange for your code example. Is it possible to create a small application that demonstrates this issue? Maybe your are getting really big input images?
I reduced the amount of code to the minimum and updated the environment of the Hosting-Provider. The Provider: "Our servers are also monitored for performance (CPU, RAM). There were no anomalies here." I hope it helps.
In the next release I have improved the error message some more. This should then also tell us the size of the image that you are creating.
Did you get this issue resolved?
Thank you for the update. I still receive an error, but different Message:
MagickImageErrorException: width or height exceeds limit `Testtext' (17x4294967292) > (33554431x33554431) @ error/cache.c/OpenPixelCache/3692
ImageMagick.MagickExceptionHelper.Check(IntPtr exception) in MagickExceptionHelper.cs
ImageMagick.NativeHelper.CheckException(IntPtr exception) in NativeHelper.cs
ImageMagick.MagickImage+NativeMagickImage.Rotate(double degrees) in MagickImage.g.cs
ImageMagick.MagickImage+CloneMutator.Rotate(double degrees) in MagickImage.CloneMutator.cs
ImageMagick.MagickImage.Rotate(double degrees) in MagickImage.cs
Sammler_Homepage.Controllers.HomeController.UploadingTest() in HomeController.cs
lambda_method91(Closure , object , object[] )
Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+SyncActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.ResponseCaching.ResponseCachingMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
For some reason it looks like you are creating an image with the size 17x4294967292 and I don't understand why that is happening. I cannot reproduce your issue locally.