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 文件 支持压缩包