排除库的原因,缩略图失败
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
4b9a277335
commit
274a8d2c21
|
|
@ -167,6 +167,9 @@ var app = builder.Build();
|
||||||
//app.UseSwaggerUI();
|
//app.UseSwaggerUI();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
//不需要 token 访问的静态文件 wwwroot css, JavaScript, and images don't require authentication.
|
||||||
|
app.UseStaticFiles();
|
||||||
|
|
||||||
SwaggerSetup.Configure(app, app.Environment);
|
SwaggerSetup.Configure(app, app.Environment);
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,22 @@
|
||||||
using IRaCIS.Core.Domain.Share;
|
using FellowOakDicom;
|
||||||
using System.Text;
|
using FellowOakDicom.Imaging;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using IRaCIS.Core.Infrastructure;
|
|
||||||
using Medallion.Threading;
|
|
||||||
using FellowOakDicom;
|
|
||||||
using FellowOakDicom.Imaging.Codec;
|
using FellowOakDicom.Imaging.Codec;
|
||||||
using System.Data;
|
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using FellowOakDicom.Network;
|
using FellowOakDicom.Network;
|
||||||
using IRaCIS.Core.SCP.Service;
|
using IRaCIS.Core.Domain.Models;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
using IRaCIS.Core.Infra.EFCore;
|
using IRaCIS.Core.Infra.EFCore;
|
||||||
using MassTransit;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
using IRaCIS.Core.Infrastructure.Extention;
|
||||||
|
using IRaCIS.Core.SCP.Service;
|
||||||
|
using MassTransit;
|
||||||
|
using Medallion.Threading;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||||
|
using System.Data;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace IRaCIS.Core.SCP.Service
|
namespace IRaCIS.Core.SCP.Service
|
||||||
{
|
{
|
||||||
|
|
@ -46,7 +49,53 @@ namespace IRaCIS.Core.SCP.Service
|
||||||
_distributedLockProvider = distributedLockProvider;
|
_distributedLockProvider = distributedLockProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<IResponseOutput> TestImage(string folderPath)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!Directory.Exists(folderPath))
|
||||||
|
return ResponseOutput.Ok("目录不存在");
|
||||||
|
|
||||||
|
// 获取所有 .dcm 文件
|
||||||
|
var dicomFiles = Directory.GetFiles(folderPath);
|
||||||
|
|
||||||
|
foreach (var fileFullPath in dicomFiles)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
public class AuToBindingStudyInfo
|
public class AuToBindingStudyInfo
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue