You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the example given by github to generate the circular image.
However, the generated image has a blac background after being exported
How do I set a transparent background? var logoRequest = (HttpWebRequest)WebRequest.Create("https://vip.ztan.net/upload/image/2023-0209/384134265131077.png"); HttpWebResponse logoResponse = (HttpWebResponse)logoRequest.GetResponse(); using Stream logoResponseStream = logoResponse.GetResponseStream(); var logo = Image.Load(logoResponseStream); logo= logo.Clone(x => x.ConvertToAvatar(new Size(80, 80), 80 / 2)); using var stream = new MemoryStream(); await logo.SaveAsync(stream, new PngEncoder()); stream.Position = 0; return stream.ToArray(); ConvertToAvatar code refer to https://github.com/SixLabors/Samples/blob/main/ImageSharp/AvatarWithRoundedCorner/Program.cs
The text was updated successfully, but these errors were encountered:
Make sure you are using a pixel format that supports an alpha component and also ensure the encoder uses a color type that supports an alpha component. Your input image will be 24bit so you need to explicitly override that.
I followed the example given by github to generate the circular image.
However, the generated image has a blac background after being exported
How do I set a transparent background?
var logoRequest = (HttpWebRequest)WebRequest.Create("https://vip.ztan.net/upload/image/2023-0209/384134265131077.png"); HttpWebResponse logoResponse = (HttpWebResponse)logoRequest.GetResponse(); using Stream logoResponseStream = logoResponse.GetResponseStream(); var logo = Image.Load(logoResponseStream); logo= logo.Clone(x => x.ConvertToAvatar(new Size(80, 80), 80 / 2)); using var stream = new MemoryStream(); await logo.SaveAsync(stream, new PngEncoder()); stream.Position = 0; return stream.ToArray();
ConvertToAvatar
code refer to https://github.com/SixLabors/Samples/blob/main/ImageSharp/AvatarWithRoundedCorner/Program.csThe text was updated successfully, but these errors were encountered: