NadekoBot Patronage system, Search commands improvements + fixes

This commit is contained in:
Kwoth
2022-06-14 07:24:33 +00:00
parent 18b10b8c6f
commit 7b5145f116
165 changed files with 14920 additions and 1457 deletions

View File

@@ -100,4 +100,25 @@ public static class ImagesharpExtensions
imageStream.Position = 0;
return imageStream;
}
public static async Task<MemoryStream> ToStreamAsync(this Image<Rgba32> img, IImageFormat? format = null)
{
var imageStream = new MemoryStream();
if (format?.Name == "GIF")
{
await img.SaveAsGifAsync(imageStream);
}
else
{
await img.SaveAsPngAsync(imageStream,
new PngEncoder()
{
ColorType = PngColorType.RgbWithAlpha,
CompressionLevel = PngCompressionLevel.DefaultCompression
});
}
imageStream.Position = 0;
return imageStream;
}
}