Resize Arithmetic operation resulted in an overflow

18 posts, 0 answers
  1. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 15 Sep 2015 Link to this post

    When trying to upload/save a .gif file I am getting the following error "Arithmetic operation resulted in an overflow.". Here is the code where the error occurs.

     

                    Telerik.Web.UI.ImageEditor.EditableImage img = e.Image;
                    
                    if (img.Width > 600 && img.Height > 600)
                        img.Resize(600, 600);
                    img.Image.Save(sFullPath + sFileName + sExt);

                    if (img.Width > 150 && img.Height > 150)
                        img.Resize(150, 150);
                    img.Image.Save(sFullPath + sThumbName + sExt);

     

    I added the code to check the size of the image before calling the Resize but it still throws the error. How do I fix this?

     

  2. Vessy
    Admin
    Vessy avatar
    1383 posts

    Posted 18 Sep 2015 Link to this post

    Hi Stephanie,

    I tested the problematic resizing logic with the image-uploading approach from this demo, but everything behaves properly on my side. The image gets resized properly and it is successfully saved with the new dimensions. For convenience I am attaching my test page to this reply - please review it and see whether it differs somehow from the one used by you. Are you able to replicate the same problem with it?

    Regards,
    Vessy
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 21 Sep 2015 in reply to Vessy Link to this post

    Thanks for the reply and the demo. Yes, I have the same and another issue with what you sent. I am attaching a screenshot of the error as well as the two .GIF images I am using. (It wouldn't let me attach them all....so this is one that causes an error even in y our code) Other images seem to resize just fine, but .gifs do not.

    Is this a bug? How do we get this fixed so we can release our software update ASAP!

  5. Vessy
    Admin
    Vessy avatar
    1383 posts

    Posted 23 Sep 2015 Link to this post

    Hi Stephanie,

    Thank you for the attached image. Unfortunately I am still not able to replicate the problem. Can you take a look over the video from my test here and see whether I am not leaving anything out? I tested the code in Firefox, IE10 and Chrome with the latest version of the controls (20152.826).

    Unfortunately we cannot be of much help without being able to reproduce and examine the issue on our side. Should you deem anything else as a possible hindrance that we might have missed so far, do not hesitate to inform us, so that we can investigate it further.

    Regards,
    Vessy
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 23 Sep 2015 in reply to Vessy Link to this post

    Thanks. I do not see a video.

    I do not know what you need to reproduce it but it is definitely an issue we need to get resolved ASAP as it is holding up our software release, so any help would be appreciated. Here is a video of my own where you can see the issue happening. You can see I have the exact same photo (size, etc) except once it was saved as a .GIF and the other is saved as a .JPG. The .jpg version works fine. The .gif errors out on the resize code. There is definitely a bug there.

    http://www.youtube.com/watch?v=zBdNGTX_IC0

  7. Vessy
    Admin
    Vessy avatar
    1383 posts

    Posted 28 Sep 2015 Link to this post

    Hi Stephanie,

    Please, excuse me for the lapse - the link to the created video is available here: http://screencast.com/t/SJiDqYcp0AS

    We understand that you need the issue resolves and are trying to help, but will need your assistance in order to determine the cause of the problem. Can you answer the questions below?
    • Which version of the controls is used in your application? Is it 2015.2.826 like stated in the ticket info?
    • In which browser and its version does the issue occur? From the recorded video I can see that the save button gets broken after click, which is an issue for IE compatibility mode and IE7. Can you verify that you are not using one of this browser modes which are not supported?
    • Can you try to replicate the issue into a stand alone runnable project and send it so we can test it on our side? I assume that there may be some specific part of your project configuration that might be the missing puzzle.
    • Can you saving handler where the problem is thrown and check the value of the img variable? Is it correctly pointing to the editable image object?

    Looking forward to your reply,
    Vessy
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 28 Sep 2015 in reply to Vessy Link to this post

    Hello Vessy,

    Thank you for the reply. As I noted in one of my previous responses, I did also receive the error with the images I also previously attached in your test version as well.

    Which version of the controls is used in your application? Is it 2015.2.826 like stated in the ticket info?

    >>  It look like it is 2015.1.401 according to the Telerik Control Panel

    In which browser and its version does the issue occur? From the recorded video I can see that the save button gets broken after click, which is an issue for IE compatibility mode and IE7. Can you verify that you are not using one of this browser modes which are not supported?

    >> Chrome Version 45.0.2454.99 m and Firefox 41.0

    Can you try to replicate the issue into a stand alone runnable project and send it so we can test it on our side? I assume that there may be some specific part of your project configuration that might be the missing puzzle.
    Can you saving handler where the problem is thrown and check the value of the img variable? Is it correctly pointing to the editable image object?

    >> It is not working with the images I sent in the version you sent to me. I can work on another standalone app I guess, but that is already not working.

     

  9. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 28 Sep 2015 in reply to Stephanie Link to this post

    I have been trying to create a standalone app for the past 4 hours but I cannot resolve the error "element XXX is not a known element' in my test app. Please help!
  10. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 28 Sep 2015 Link to this post

    Okay, I got that fixed. I think is was because i was going from a website to a web project. Now when I run this. I get my page but the upload button, and select, etc are not there? This is why creating a 'standalone' is such a pain in the butt :)
  11. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 28 Sep 2015 Link to this post

    Okay, now I am really confused :) I copied just the popup window from our original website and put in a brand new page with a link to open that popup and that works just fine. The resize code is exactly the same. So, what else could interfere with the resize code and cause the initial error for .gif files only?
  12. Vessy
    Admin
    Vessy avatar
    1383 posts

    Posted 29 Sep 2015 Link to this post

    Hi Stephanie,

    Thank you for spending time on isolating the problem. My assumption is that the problem is related with some configurations on an application level. My suggestion is to compare both the configurations of your original project and the isolated one and see how they differ.

    Regards,
    Vessy
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  13. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 29 Sep 2015 in reply to Vessy Link to this post

    Hello,

    I agree obviously there is something in the full project that is in conflict, my hope was you could point me into what would cause the Resize function on the ImageEditor to throw the 'Overflow' error since the error is coming directly from the Telerik control, it is hard for me to figure out beyond this. The isolated project had the same web.config file and the save code is exactly the same as well. I will keep looking but if you have any ideas on where would be the most productive that would be great since I don't really have days to spend on this.....Thanks!

  14. Vessy
    Admin
    Vessy avatar
    1383 posts

    Posted 30 Sep 2015 Link to this post

    Hi Stephanie,

    The graphics core of RadImageEditor is the .NET standard GDI+ library and there are some limitations coming from it that cannot be controlled by us. We do want to help you in resolving the problem, but as we are not previously aware of such behavior there is no much we can do without being able to replicate and examine the case on our side.

    The only remaining suggestion I can give you is to test the problematic image directly by resizing it through GDI+, without going through the RadImageEditor's API and see whether the problem still persist. In order to make such a test you have go go through the following steps:
    • De-archive the attached zip inside the Root folder of the problematic project (the initial one, not the isolated version)
    • Open GDIResize.aspx.cs file and change the path passed to the original image object in order to point one of the problematic images

    Please make the test above and let us know the results from it.

    Regards,
    Vessy
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  15. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 01 Oct 2015 in reply to Vessy Link to this post

    Hello Vessy,

    Thank you for your continued help! I did exactly what you suggested and still get the attached error?...

     

    How can we accomplish uploading a .gif file and resizing it?

  16. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 01 Oct 2015 in reply to Stephanie Link to this post

    Whoops :) I lied that error was on saving not resizing. So the resize seems to work this way. What on earth would be causing the exact same code to error in the other page of the application. I am out of ideas as to what to check at this point.
  17. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 01 Oct 2015 in reply to Stephanie Link to this post

    Okay, in comparing what you sent to what we have I see that in the 'test' with GDI the image is defined as follows:

    Bitmap originalImage = new Bitmap("C:\\dt7odrjbc.gif");

    Image img = (Image)originalImage;

    ** so img is a System.Drawing.Image

     

    In our code we have the following:

    Telerik.Web.UI.ImageEditor.EditableImage img = e.Image;

    ** So img is a Telerik.Web.UI.ImageEditor.EditableImage

     

    The "Resize()" method is called on the image so I am assuming those are different between the two types of images?

     

    So it looks like the resize on the ImageEditor image is the issue.

  18. Stephanie
    Stephanie avatar
    139 posts
    Member since:
    Aug 2013

    Posted 01 Oct 2015 in reply to Stephanie Link to this post

    Okay so I made some changes to make our code use the System.Drawing.Image from the ImageEditor to do the resize using the method you provided in the test. Here is the new code:

                    string sFullPath = Server.MapPath(Dog.GetDocumentDir(lDog) + "/");
                    string sExt = "." + e.Image.Format;
                    string sFileName = Guid.NewGuid().ToString();
                    string sThumbName = sFileName + "_t";

                    Telerik.Web.UI.ImageEditor.EditableImage img = e.Image;
                    System.Drawing.Image originalImage = img.Image;

                    if (img.Width > 600 && img.Height > 600)
                        originalImage = Resize(originalImage, new Size(600, 600), InterpolationMode.Bicubic);
                    originalImage.Save(sFullPath + sFileName + sExt);

                    if (img.Width > 150 && img.Height > 150)
                        originalImage = Resize(originalImage, new Size(150, 150), InterpolationMode.Bicubic);
                    originalImage.Save(sFullPath + sThumbName + sExt);

     

    While I no longer get an error uploading the attached gif, the resized image is 'skewed' and not proportional....

     

     

     

  19. Vessy
    Admin
    Vessy avatar
    1383 posts

    Posted 06 Oct 2015 Link to this post

    Hi Stephanie,

    The Resizing logic provided in my previous reply is the resizing logic used inside RadImageEditor. The EditableImage contains an System.Drawing.Image instance of the currently edited image and use it during the resizing process.

    As for the proportions of the resized image, it is expected as the image is resized to 150x150 in width and height in the given by me sample. You will need to keep the width:height proportion of the image before the resizing in order to resize it depending on that:
    protected void RadImageEditor1_ImageSaving(object sender, ImageEditorSavingEventArgs e)
    {
        string sFullPath = Server.MapPath("~/Uploads/");
        string sFileName = "testImage" + DateTime.Now.Ticks;
        string sExt = ".gif";
        string sThumbName = sFileName + "_thumb";
        Telerik.Web.UI.ImageEditor.EditableImage img = e.Image;
        int newHeight;
     
        if (img.Width > 600 && img.Height > 600)
        {
            newHeight = (int)(600 * (double)img.Height / img.Width);
            img.Resize(600, newHeight);
        }
        img.Image.Save(sFullPath + sFileName + sExt);
     
        if (img.Width > 150 && img.Height > 150)
        {
            newHeight = (int)(150 * (double)img.Height / img.Width);
            img.Resize(150, newHeight);
        }
        img.Image.Save(sFullPath + sThumbName + sExt);
     
        e.Cancel = true;
    }

    Regards,
    Vessy
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017