From 76aa9de80c7c56aecc5abc2c395dc8dd99d76416 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 19 May 2022 16:35:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=9B=BE=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/QC/NoneDicomStudyService.cs | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs index 60b8c52a6..805edc6dc 100644 --- a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs @@ -14,6 +14,8 @@ using IRaCIS.Core.Application.Service.Inspection.DTO; using Nito.AsyncEx; using IRaCIS.Application.Interfaces; using IRaCIS.Core.Infrastructure; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp; namespace IRaCIS.Core.Application.Contracts { @@ -205,15 +207,32 @@ namespace IRaCIS.Core.Application.Contracts } - //[HttpGet] - //public async Task NoneDicomFilePreview(string relativePath) - //{ - // var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName; + [HttpGet] + public async Task NoneDicomFilePreview(string relativePath) + { + var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName; - // var _fileStorePath = Path.Combine(rootPath, relativePath); + var _fileStorePath = Path.Combine(rootPath, relativePath); - - //} + var storePreviewPath = _fileStorePath + ".preview.jpeg"; + + if (!File.Exists(storePreviewPath)) + { + + using (var image = SixLabors.ImageSharp.Image.Load(await File.ReadAllBytesAsync(_fileStorePath))) + { + image.Mutate(x => x + .Resize(image.Width / 2, image.Height / 2) + ); + + await image.SaveAsJpegAsync(storePreviewPath); + + } + } + + return new FileContentResult(await File.ReadAllBytesAsync(storePreviewPath), "image/jpeg"); + + } /// /// 上传非Dicom 文件 支持压缩包