Hi there,
I need to change resolution of an Image on Blazor Client-Side.
I tried with this code:
public static class IncreaseImgResolution { public static async Task<string> IncreaseDpi(string base64IngString, float moltiplicatioFactor) { return await Task.Run(() => EnchangeImgDpi(base64IngString, moltiplicatioFactor)); } private static string EnchangeImgDpi(string base64IngString, float moltiplicatioFactor) { byte[] imageBytes = Convert.FromBase64String(base64IngString); var ms = new MemoryStream(imageBytes, 0, imageBytes.Length); var OriginalBitmap = new Bitmap(ms); var vertRes = OriginalBitmap.VerticalResolution * moltiplicatioFactor; var horRes = OriginalBitmap.HorizontalResolution * moltiplicatioFactor; OriginalBitmap.SetResolution(horRes, vertRes); using (var stream = new MemoryStream()) { OriginalBitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png); var str = stream.ToArray(); return Convert.ToBase64String(str); } } }
But I retrieve following error:
blazor.webassembly.js:1 WASM: System.PlatformNotSupportedException: Operation is not supported on this platform.
At following line of code:
var OriginalBitmap = new Bitmap(ms);
So, I think System.Drawing is not working on webassembly.
I would like to know if somebody can suggest some workaround or alternative solutions.
Thank you