Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 22, 2010 @ 18:03
    Jeroen Breuer
    1

    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

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Sep 23, 2010 @ 12:33
    Douglas Robar
    0

    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:

    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?

    cheers,
    doug.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 23, 2010 @ 12:52
    Jeroen Breuer
    0

    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

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Sep 23, 2010 @ 12:55
    Douglas Robar
    0

    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.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Dec 01, 2010 @ 12:13
    Anthony Dang
    0

    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.

     

     

  • Michael Worrall 57 posts 82 karma points
    Jul 24, 2012 @ 12:06
    Michael Worrall
    0

    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.

  • Murray Roke 503 posts 966 karma points c-trib
    Aug 07, 2012 @ 05:10
    Murray Roke
    0

    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.

  • Jan Vermeerbergen 79 posts 112 karma points
    Aug 17, 2012 @ 11:36
    Jan Vermeerbergen
    0

    I'm having the same problem here. Anybody found a solution to this ?

  • Mark 255 posts 612 karma points
    Sep 21, 2012 @ 15:29
    Mark
    0

    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?

  • Mark 255 posts 612 karma points
    Sep 21, 2012 @ 15:34
    Mark
    0

    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

  • Lari Kovanen 2 posts 21 karma points
    Nov 21, 2012 @ 08:23
    Lari Kovanen
    0

    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.

  • Bert Loedeman 10 posts 30 karma points
    Nov 23, 2012 @ 01:06
    Bert Loedeman
    0

    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...

  • Bert Loedeman 10 posts 30 karma points
    Nov 23, 2012 @ 01:06
    Bert Loedeman
    0

    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...

  • Mikkel Johansen 116 posts 292 karma points
    Jan 18, 2013 @ 11:44
    Mikkel Johansen
    0

    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

     

  • Ian Smedley 97 posts 192 karma points
    Jun 10, 2013 @ 13:57
    Ian Smedley
    0

    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?

  • andrew shearer 510 posts 659 karma points
    Nov 12, 2013 @ 05:55
    andrew shearer
    0

    +1, seeing this in umbraco 4.9.1

Please Sign in or register to post replies

Write your reply to:

Draft