I've been toying with the new Image cropper of Umbraco 4.5 and I really like it, but now I get this exception if I try to crop an image:
Out of memory. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.OutOfMemoryException: Out of memory.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
as the stack trace says then it sure sounds like your app pool has indeed run out of memory. Remember that an image is expanded to its full size, which is quite large if the source image is big.
The calculation for the amount of memory used by the image is:
Image Width in Pixels * Image Height in Pixels * 3bits/pixel for RGB images / 1024 / 1024
And then that amount get's cloned so your app pool needs twice the memory to crop the image. If you app pool is memory-limited or your images are very large you could readily run out of memory.
An example: 1280x1024 source image requires 3.75 MB of memory when uncompressed. (x2 when cloned)
An example: 10MP image from camera requires 30MB of memory when uncompressed (x2 when cloned)
An example: 21MP image from my Canon 5D MkII requires 62MB of memory when uncompressed (x2 when cloned)
I agree the error should be trapped and handled gracefully, but the cause of the issue may not be ImageCropper related, per se.
What size images are you trying to crop when this happens? How much memory does your app pool have assigned to it?
Yup, 800x600 would only need 1.4MB and I would hope you'd have that available :)
Interesting potential of having an image 1px off. Maybe that's it. Would love to hear more, and why everyone doesn't have this problem. That is, in what conditions does this happen?
Ditto 4.7.1.1, reported from client, the image was only 450x276 I don't have any indication if there was any memory pressure at the time.
I've looked at the src and see there's no using statements wrapping Bitmap. images will not be disposed correctly, and apparently GC is notiorious for failing to collect these types of memory resources in a timely fashion
I too am having the issue on a 4.7.1.1 site. To recreate the problem I simply move the left edge of the crop, either by resizing from the bottom left corner, or by dragging to the right a crop that is not the full width. Does this help, Douglas?
Just to add to that, the crops are wider than they are high, and the crop being resized or dragged, touches the right edge of the original image. If it doesn't go to the right edge, it saves fine. Plus the aspect ratio of the crop allows it to span the full width of the original
Just like Mark i get an Out of memory exception if the crop touches the right edge of the original image. Any solution in sight for this problem? This occurs on our 4.9.0 installation. Haven't tried later versions yet.
Image cropper out of memory
I've been toying with the new Image cropper of Umbraco 4.5 and I really like it, but now I get this exception if I try to crop an image:
Out of memory.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.OutOfMemoryException: Out of memory.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[OutOfMemoryException: Out of memory.]
System.Drawing.Bitmap.Clone(Rectangle rect, PixelFormat format) +457510
umbraco.editorControls.imagecropper.ImageTransform.cropImage(Image img, Rectangle cropArea) +152
umbraco.editorControls.imagecropper.ImageTransform.Execute(String sourceFile, String name, Int32 cropX, Int32 cropY, Int32 cropWidth, Int32 cropHeight, Int32 sizeWidth, Int32 sizeHeight, Int64 quality) +666
umbraco.editorControls.imagecropper.ImageInfo.GenerateThumbnails(SaveData saveData, Config config) +639
umbraco.editorControls.imagecropper.DataEditor.Save() +257
umbraco.controls.ContentControl.saveClick(Object Sender, ImageClickEventArgs e) +268
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +115
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +120
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
I use the cropper on the Image MediaType to crop an image.
I also added a codeplex issue for this: http://umbraco.codeplex.com/workitem/28944
Jeroen
If the out of memory error happens during
System.Drawing.Bitmap.Clone()
as the stack trace says then it sure sounds like your app pool has indeed run out of memory. Remember that an image is expanded to its full size, which is quite large if the source image is big.
The calculation for the amount of memory used by the image is:
And then that amount get's cloned so your app pool needs twice the memory to crop the image. If you app pool is memory-limited or your images are very large you could readily run out of memory.
An example: 1280x1024 source image requires 3.75 MB of memory when uncompressed. (x2 when cloned)
An example: 10MP image from camera requires 30MB of memory when uncompressed (x2 when cloned)
An example: 21MP image from my Canon 5D MkII requires 62MB of memory when uncompressed (x2 when cloned)
I agree the error should be trapped and handled gracefully, but the cause of the issue may not be ImageCropper related, per se.
What size images are you trying to crop when this happens? How much memory does your app pool have assigned to it?
cheers,
doug.
I first resize the image to 800x600 before I use the image cropper so that probably isn't the problem. Richard Soeteman tweeted this:
I had the same issue at a client it appears that the crop was 1 px greater than the actual image :-( Hacked the source...
I think that's the problem because in some situations my crop also could become bigger than the actual image.
Jeroen
Yup, 800x600 would only need 1.4MB and I would hope you'd have that available :)
Interesting potential of having an image 1px off. Maybe that's it. Would love to hear more, and why everyone doesn't have this problem. That is, in what conditions does this happen?
cheers,
doug.
It seems that I'm having this problem too. Nothing more I can add to Jeroen's stack trace. It's exactly the same as mine.
Did anyone ever figure out why this happens? I'm having the exact same problem, but with 4.7.1 and no memory limit on my app pool.
Ditto 4.7.1.1, reported from client, the image was only 450x276 I don't have any indication if there was any memory pressure at the time.
I've looked at the src and see there's no using statements wrapping Bitmap. images will not be disposed correctly, and apparently GC is notiorious for failing to collect these types of memory resources in a timely fashion
see more:
http://www.hanselminutes.com/313/deep-inside-image-resizing-and-scaling-with-aspnet-and-iis-with-imageresizingnet-author-na
follow show links also.
I'm having the same problem here. Anybody found a solution to this ?
I too am having the issue on a 4.7.1.1 site. To recreate the problem I simply move the left edge of the crop, either by resizing from the bottom left corner, or by dragging to the right a crop that is not the full width. Does this help, Douglas?
Just to add to that, the crops are wider than they are high, and the crop being resized or dragged, touches the right edge of the original image. If it doesn't go to the right edge, it saves fine. Plus the aspect ratio of the crop allows it to span the full width of the original
Just like Mark i get an Out of memory exception if the crop touches the right edge of the original image. Any solution in sight for this problem? This occurs on our 4.9.0 installation. Haven't tried later versions yet.
I experience it too. When I get the right corner loose from the right side, all seems well... I am using v4.10.1 by the way...
I experience it too. When I get the right corner loose from the right side, all seems well... I am using v4.10.1 by the way...
It is still a problem in 4.11.3
Looks like it has been fixed and will be released in version 6 :-)
http://issues.umbraco.org/issue/U4-335
I am seeing this issue on 6.1.1 (an upgrade from 6.0.0)
umbraco.editorControls version 1.0.4902.15218
Is anyone else experincing this?
+1, seeing this in umbraco 4.9.1
is working on a reply...