Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 14.4.0: Error MagickImageErrorException: width or height exceeds limit, when using MagickImage Rotate #1798

Open
markusRettenmeier opened this issue Feb 22, 2025 · 6 comments

Comments

@markusRettenmeier
Copy link

markusRettenmeier commented Feb 22, 2025

Magick.NET version

14.4.0

Environment (Operating system, version and so on)

C#, Windows x86, ASP.NET 9.0

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:

MagickReadSettings readSettings = new()
 {
     Font = "Calibri",
     TextGravity = Gravity.Center,
     BackgroundColor = MagickColors.Transparent,
     FillColor = MagickColors.LightGray,
     Height = 200,
     Width = 400
 };
 MagickImage watermark = new($"caption:{watermarkText}", readSettings);
 watermark.Rotate(315);

After removing watermark.Rotate(); It doesn't occure anymore.

@dlemstra
Copy link
Owner

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?

@dlemstra
Copy link
Owner

Can you upgrade to 14.5.0? This should provide you with a better error message.

@markusRettenmeier
Copy link
Author

I updated to 14.5.0, still the same.
I contact my Hosting-Provider, if he could get me information about the environment.

@dlemstra
Copy link
Owner

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?

@markusRettenmeier
Copy link
Author

I added the raw exception details
unfortunatelly now the code snippet is not so easy to read anymore.
Sorry

@dlemstra
Copy link
Owner

dlemstra commented Feb 25, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants