19 lines
673 B
C#
19 lines
673 B
C#
using HamyanEdalat.Common.Models.Api;
|
|
using SixLabors.ImageSharp;
|
|
using SixLabors.ImageSharp.Processing;
|
|
|
|
namespace HamyanEdalat.Core.Utilities;
|
|
|
|
public static class ImageConvertor
|
|
{
|
|
public static async Task<Stream> ImageResize(this FileUploadRequest fileUpload, Stream input, Stream output, int newWidth)
|
|
{
|
|
using var image = await Image.LoadAsync(input);
|
|
var height_width = image.Height / image.Width;
|
|
var new_Height = newWidth * height_width;
|
|
image.Mutate(x => x.Resize(newWidth, new_Height));
|
|
image.Mutate(x => x.Resize(newWidth, new_Height));
|
|
await image.SaveAsJpegAsync(output);
|
|
return output;
|
|
}
|
|
} |