irc-netcore-api/IRaCIS.Core.Application/Helper/ImageResize.cs

27 lines
742 B
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
namespace IRaCIS.Core.Application.Helper;
public static class ImageResizeHelper
{
// 采用ImageSharp组件 跨平台不依赖windows 平台图像处理组件,这里大坑(net 6 下之前由于Dicom处理最新组件 依赖了这个库的一个旧版本导致缩略图bug单独升级依赖组件才解决)
public static void ResizeSave(string filePath, string? fileStorePath)
{
fileStorePath = fileStorePath ?? filePath + ".preview.jpeg";
using (var image = SixLabors.ImageSharp.Image.Load(filePath))
{
image.Mutate(x => x.Resize(500, 500));
image.Save(fileStorePath);
}
}
}