This is a migrated thread and some comments may be shown as answers.

Resize Arithmetic operation resulted in an overflow

17 Answers 175 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
DogBizPro
Top achievements
Rank 1
DogBizPro asked on 16 Sep 2015, 12:59 AM

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?

 

17 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 18 Sep 2015, 11:37 AM
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
0
DogBizPro
Top achievements
Rank 1
answered on 21 Sep 2015, 07:02 PM

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!

0
Vessy
Telerik team
answered on 23 Sep 2015, 05:52 PM
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
0
DogBizPro
Top achievements
Rank 1
answered on 23 Sep 2015, 06:06 PM

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

0
Vessy
Telerik team
answered on 28 Sep 2015, 02:17 PM
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
0
DogBizPro
Top achievements
Rank 1
answered on 28 Sep 2015, 03:09 PM

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.

 

0
DogBizPro
Top achievements
Rank 1
answered on 28 Sep 2015, 06:06 PM
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!
0
DogBizPro
Top achievements
Rank 1
answered on 28 Sep 2015, 06:15 PM
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 :)
0
DogBizPro
Top achievements
Rank 1
answered on 28 Sep 2015, 06:59 PM
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?
0
Vessy
Telerik team
answered on 29 Sep 2015, 12:17 PM
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
0
DogBizPro
Top achievements
Rank 1
answered on 29 Sep 2015, 01:18 PM

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!

0
Vessy
Telerik team
answered on 30 Sep 2015, 08:38 AM
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
0
DogBizPro
Top achievements
Rank 1
answered on 01 Oct 2015, 03:51 PM

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?

0
DogBizPro
Top achievements
Rank 1
answered on 01 Oct 2015, 03:54 PM
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.
0
DogBizPro
Top achievements
Rank 1
answered on 01 Oct 2015, 04:35 PM

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.

0
DogBizPro
Top achievements
Rank 1
answered on 01 Oct 2015, 04:53 PM

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

 

 

 

0
Vessy
Telerik team
answered on 06 Oct 2015, 06:06 AM
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
Tags
ImageEditor
Asked by
DogBizPro
Top achievements
Rank 1
Answers by
Vessy
Telerik team
DogBizPro
Top achievements
Rank 1
Share this question
or