Blur image after resizing and conversion to base64 string
Description
I am converting resized image to byte array and then to base64 so i could show it on frontend side.
Steps to reproduce
Resizing: sourceImage.Mutate(x => x.Resize(width, height));
I also tried with: sourceImage.Mutate(x => x.Resize(new ResizeOptions { Size = new Size(width, height), Mode = ResizeMode.Max })); but still the same, i can not get sharp image.
Conversion to base64: using (var outputStream = new MemoryStream()) { image.Save(outputStream, new JpegDecoder()); var bytes = outputStream.ToArray(); return Convert.ToBase64String(bytes); }
Am I missing something?
Thanks
System Configuration
- Environment (Operating system, version and so on): Windows 10
- .NET Framework version: .NET Core 2.0
- Additional information:
Have you compared the output of the encoder saving to a file to the redecoded output from your image viewer? Encoding the byte array to a string simply encoded the bytes, the method is lossless.
@z-tc Hello?
sorry for delay, seems that my css on web client managed to break image aspect ratio. for some reason base64 image fits in all my divs correctly without resizing, so when i do the resize, resized image stretch to fill the div and i get blur image. so, library is doing the job well on the end. thanks for quick answer
Ah awesome, good to know, thanks! 😄