diff --git a/IRC.Core.SCP/Service/CStoreSCPService.cs b/IRC.Core.SCP/Service/CStoreSCPService.cs index ce84949a6..6390fc803 100644 --- a/IRC.Core.SCP/Service/CStoreSCPService.cs +++ b/IRC.Core.SCP/Service/CStoreSCPService.cs @@ -728,7 +728,7 @@ namespace IRaCIS.Core.SCP.Service // 上传缩略图到 OSS - var seriesPath = await ossService.UploadToOSSAsync(memoryStream, ossFolderPath, seriesId.ToString() + ".preview.jpg", false); + var seriesPath = await ossService.UploadToOSSAsync(memoryStream, ossFolderPath, $"{seriesId.ToString()}_{instanceId.ToString()}.preview.jpg", false); Console.WriteLine(seriesPath + " Id: " + seriesId); diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index 9c061d9cb..87f938d98 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -1,4 +1,5 @@ using Aliyun.OSS; +using DocumentFormat.OpenXml.Bibliography; using FellowOakDicom; using FellowOakDicom.Imaging; using IRaCIS.Application.Contracts; @@ -27,6 +28,7 @@ using Microsoft.Extensions.Options; using MiniExcelLibs; using NPOI.SS.Formula.Functions; using NPOI.XWPF.UserModel; +using SixLabors.ImageSharp.Formats.Jpeg; using System.Globalization; using System.Runtime.InteropServices; using System.Text; @@ -57,6 +59,31 @@ namespace IRaCIS.Core.Application.Service public static int IntValue = 100; + public async Task TestImage(string fileFullPath) + { + var file = await DicomFile.OpenAsync(fileFullPath); + // 生成缩略图 + using (var memoryStream = new MemoryStream()) + { + DicomImage image = new DicomImage(file.Dataset); + + var sharpimage = image.RenderImage().AsSharpImage(); + sharpimage.Save(memoryStream, new JpegEncoder()); + + + // 关键点:一定要回到开头 + memoryStream.Position = 0; + + using (var fileStream = File.Create($"{fileFullPath}.jpg")) + { + await memoryStream.CopyToAsync(fileStream); + } + + } + + return ResponseOutput.Ok(); + } + /// /// 维护dir 需求新增的字段