Resizing an image always fails and causes an internal exception to happen

Hi,

A while ago I had already contacted support about the resizing-feature of the Image Editor not working. Since then it was supposed to be fixed, however after making the updates and testing it once more something else happened.

Previously it silently failed, the image just simply failed to resize and then execution continued onwards. Currently this behaviour has changed, now after it has failed to resize it will throw a NullReferenceException when attempting to access the ImageData by a method once more.

The question is, what are the requirements for making a resize-action work in the first place?


Here's a quick example of the code being used and where it is failing, this method is called on a button click:

private async Task SyncfusionSupportExample()

{

    if (ImageEditor == null)

        return;


    await ImageEditor.CropAsync();


    // This will retrieve the image data correctly

    var imageData = await ImageEditor.GetImageDataAsync();


    // This will always return false, indicating that resizing failed. This has been tested with different images.

    var isSuccesFull = await ImageEditor.ImageResizeAsync(300, 300, isAspectRatio: true);


    // Causes a NULLREFERENCEEXCEPTION - somehow the image data inside the editor has become nullified

    // Do note, this does not happen when the resize method above is not called

    var imageData2 = await ImageEditor.GetImageDataAsync();


    await ImageEditor.ExportAsync("resized-image-name", ImageEditorFileType.PNG);

}


4 Replies 1 reply marked as answer

KV Keerthikaran Venkatachalam Syncfusion Team April 25, 2024 02:12 PM UTC

Hi Mika,


We have attempted to replicate the issue on our end but were unable to do so. We have prepared the sample based on your provided code snippet. It is working fine on our end. I have attached the video demonstrations and sample for reference.


For further validation, could you please share the issue's replicable working sample or replicate the issue in our sample with replication steps and a video demonstration, and share which package version you are using in your project? Based on that, we will check and provide you with a better solution quickly.


If you are using a lower package version, kindly update the Syncfusion package to the latest version (25.1.41) and check on your end.


Please let us know if you need any further assistance on this.


Regards,

KeerthiKaran K V


Attachment: ImageEditorSample_f328d5f3.zip


MI Mika April 25, 2024 03:06 PM UTC

I am using the latest version, 25.1.41 that is.

The main difference I've seen between the sample and my own implementation is that the image is not opened through the OpenAsync()-method but instead by letting the user upload it themself.

Besides that, the execution path between the sample and my own code seems to be the same.

I've include a zip to the attachments, there you'll find the file responsible for making the upload and a gif to show my own actions.

Also interesting to take note of is an internal exception thrown inside the .js file responsible for making the resize event happen.

Perhaps good to know is that we're using Blazor Server and .NET 8.0 for our project.



Attachment: editorissues_cbf7e81a.zip


KV Keerthikaran Venkatachalam Syncfusion Team April 26, 2024 01:36 PM UTC

Hi Mika,


We are pleased to inform you that we have successfully resolved the “Script error thrown in ImageEditor when using ImageResizeAsync and GetImageDataAsync method". It will be reflected in the upcoming weekly release scheduled for next week. You will be informed regarding this once the fix is published.

For now, please use the below-attached custom package until then.


Package Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Syncfusion.Blazor.100.2.1-2070095798.zip


Regards,

KeerthiKaran K V


Marked as answer

KV Keerthikaran Venkatachalam Syncfusion Team April 30, 2024 12:03 PM UTC

Hi Mika,


We are glad to announce that our weekly patch release (25.1.42) has been rolled out. We have included the fix for this “Script error thrown in ImageEditor when using ImageResizeAsync and GetImageDataAsync method” issue in this release. So, we suggest you upgrade our Syncfusion packages to our latest version to resolve this issue on your end (25.1.42).


Root cause: The underlying reason for the problem is that we did not check the null element condition for the aspectRatioHeight variable when using the ImageResizeAsync and GetImageDataAsync methods in the Blazor image editor.


Package link: https://www.nuget.org/packages/Syncfusion.Blazor.ImageEditor 


Get back to us if you need any further assistance on this.


Regards,

KeerthiKaran K V


Loader.
Up arrow icon