27 lines
742 B
C#
27 lines
742 B
C#
|
||
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);
|
||
|
||
}
|
||
}
|
||
}
|
||
|