Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize Image (jpg) in Blazor WebAssembly?

What is the best way to resize an image that is uploaded on a Blazor client page. These are real simple images that I just wanted to have a consistent width and was hoping to use the System.Drawing, but that is not available in web assembly. I was hoping to do it on the client, but is it best to send it to a Controller for processing?

Thanks, Mike

like image 291
Mike Avatar asked Nov 07 '22 07:11

Mike


1 Answers

.NET 5 has an extension method to IBrowserFile called RequestImageFileAsync. Per the documentation, it "Attempts to convert the current image file to a new one of the specified file type and maximum file dimensions."

like image 82
Dan Ott Avatar answered Nov 15 '22 05:11

Dan Ott