Chronostasys / Blazor.Cropper

A blazor library provides component to crop image
MIT License
84 stars 19 forks source link

ImageCroppedResult.GetBase64Async is obsolete #34

Closed kevonh closed 2 years ago

kevonh commented 2 years ago

this api is obsolete in dotnet 6 for bad performance

What should this be replaced with?

Chronostasys commented 2 years ago

Well, if you want to get the image data in bytes, call GetDataAsync. If you want to save result to stream, use SaveAsync .
Generally, base64 is only useful when we want to display the cropped result in browser. In this situation, transfer byte array to js and encode it to base64 by calling URL.createObjectURL (like here). It's many times faster than doing base64 encode in dotnet first and then transfer the large string to javascript(in dotnet 6).
GetBase64Async api is used in dotnet 5 because everything transfered between dotnet and js before dotnet 6 is base64 encoded. In dotnet 6, byte array can be transfered directly between dotnet and js, that's why it's obsolete.