缩略图测试
parent
04a24ea438
commit
ca1f23ca4d
|
@ -0,0 +1,94 @@
|
||||||
|
using AutoMapper;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using IRaCIS.Core.Infrastructure.Extention;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.API.Controllers
|
||||||
|
{
|
||||||
|
[ApiExplorerSettings(GroupName = "Trial")]
|
||||||
|
[ApiController]
|
||||||
|
public class CommonController : ControllerBase
|
||||||
|
{
|
||||||
|
public IMapper _mapper { get; set; }
|
||||||
|
public IUserInfo _userInfo { get; set; }
|
||||||
|
|
||||||
|
private readonly IWebHostEnvironment _hostEnvironment;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public CommonController(IMapper mapper, IUserInfo userInfo, IMediator mediator, IWebHostEnvironment hostEnvironment)
|
||||||
|
{
|
||||||
|
_hostEnvironment = hostEnvironment;
|
||||||
|
_mapper = mapper;
|
||||||
|
_userInfo = userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpGet("Common/LocalFilePreview")]
|
||||||
|
public async Task<FileContentResult> LocalFilePreview(string relativePath)
|
||||||
|
{
|
||||||
|
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
|
||||||
|
|
||||||
|
var _fileStorePath = Path.Combine(rootPath, relativePath.Replace('/', '\\').Trim('\\'));
|
||||||
|
|
||||||
|
|
||||||
|
var storePreviewPath = _fileStorePath + ".preview.jpeg";
|
||||||
|
|
||||||
|
//if (!System.IO.File.Exists(storePreviewPath))
|
||||||
|
//{
|
||||||
|
ImageResizeHelper.ResizeSave(_fileStorePath, storePreviewPath);
|
||||||
|
//}
|
||||||
|
|
||||||
|
return new FileContentResult(await System.IO.File.ReadAllBytesAsync(storePreviewPath), "image/jpeg");
|
||||||
|
|
||||||
|
//_logger.LogError(rootPath);
|
||||||
|
|
||||||
|
//_logger.LogError(_fileStorePath);
|
||||||
|
|
||||||
|
|
||||||
|
//if (!File.Exists(storePreviewPath))
|
||||||
|
//{
|
||||||
|
|
||||||
|
//Bitmap sourceImage = new Bitmap(File.OpenRead(_fileStorePath));
|
||||||
|
|
||||||
|
//System.Drawing.Image destinationImage = new Bitmap(500, 500);
|
||||||
|
//Graphics g = Graphics.FromImage(destinationImage);
|
||||||
|
|
||||||
|
//g.DrawImage(
|
||||||
|
// sourceImage,
|
||||||
|
// new Rectangle(0, 0, 500, 500),
|
||||||
|
// new Rectangle(0, 0, sourceImage.Width, sourceImage.Height),
|
||||||
|
// GraphicsUnit.Pixel
|
||||||
|
//);
|
||||||
|
|
||||||
|
//destinationImage.Save(storePreviewPath);
|
||||||
|
|
||||||
|
//var image = SKBitmap.Decode(_fileStorePath);
|
||||||
|
////设置图片新的size
|
||||||
|
//var newImg = image.Resize(new SKSizeI(50, 50), SKFilterQuality.Medium);
|
||||||
|
//using var fs = new FileStream(storePreviewPath, FileMode.Create);
|
||||||
|
//newImg.Encode(fs, SKEncodedImageFormat.Png, 100);
|
||||||
|
//fs.Flush();
|
||||||
|
|
||||||
|
|
||||||
|
//var image = NetVips.Image.NewFromFile(_fileStorePath);
|
||||||
|
//var newImg = image.Resize(0.5);
|
||||||
|
//newImg.WriteToFile(storePreviewPath);
|
||||||
|
|
||||||
|
|
||||||
|
//var image = NetVips.Image.NewFromFile(_fileStorePath);
|
||||||
|
//var newImg = image.ThumbnailImage(500);
|
||||||
|
//newImg.WriteToFile(_fileStorePath);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Application.Helper;
|
||||||
|
|
||||||
|
public static class ImageResizeHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -82,14 +82,18 @@
|
||||||
<PackageReference Include="MimeKit" Version="3.2.0" />
|
<PackageReference Include="MimeKit" Version="3.2.0" />
|
||||||
<PackageReference Include="MiniExcel" Version="1.26.1" />
|
<PackageReference Include="MiniExcel" Version="1.26.1" />
|
||||||
<PackageReference Include="My.Extensions.Localization.Json" Version="3.0.0" />
|
<PackageReference Include="My.Extensions.Localization.Json" Version="3.0.0" />
|
||||||
|
<PackageReference Include="NetVips" Version="2.1.0" />
|
||||||
|
<PackageReference Include="NetVips.Native" Version="8.12.2" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
|
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
|
||||||
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.0" />
|
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.0" />
|
||||||
<PackageReference Include="Quartz" Version="3.4.0" />
|
<PackageReference Include="Quartz" Version="3.4.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
||||||
|
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.3.0" />
|
||||||
|
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.17.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.17.0" />
|
||||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.18" />
|
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.18" />
|
||||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
public string FullFilePath { get; set; } = string.Empty;
|
public string FullFilePath { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string PreviewPath => "/Common/LocalFilePreview?relativePath=" + Path;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
|
|
||||||
public List<NoneDicomStudyFileView> NoneDicomStudyFileList { get; set; } = new List<NoneDicomStudyFileView>();
|
public List<NoneDicomStudyFileView> NoneDicomStudyFileList { get; set; } = new List<NoneDicomStudyFileView>();
|
||||||
|
|
||||||
|
public List<string> NoneDicomStudyPreviewList=> NoneDicomStudyFileList.Select(t=> t.PreviewPath).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>NoneDicomStudyQuery 列表查询参数模型</summary>
|
///<summary>NoneDicomStudyQuery 列表查询参数模型</summary>
|
||||||
|
|
|
@ -14,10 +14,13 @@ using IRaCIS.Core.Application.Service.Inspection.DTO;
|
||||||
using Nito.AsyncEx;
|
using Nito.AsyncEx;
|
||||||
using IRaCIS.Application.Interfaces;
|
using IRaCIS.Application.Interfaces;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using SixLabors.ImageSharp.Processing;
|
|
||||||
using SixLabors.ImageSharp;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using System.Drawing;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Contracts
|
namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
|
@ -212,37 +215,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
return await _repository.Where<NoneDicomStudyFile>(t => t.NoneDicomStudy.SubjectVisitId == subjectVisitId).ProjectTo<NoneDicomStudyFileView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken }).ToListAsync();
|
return await _repository.Where<NoneDicomStudyFile>(t => t.NoneDicomStudy.SubjectVisitId == subjectVisitId).ProjectTo<NoneDicomStudyFileView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken }).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
|
||||||
[HttpGet]
|
|
||||||
public async Task<FileContentResult> NoneDicomFilePreview(string relativePath)
|
|
||||||
{
|
|
||||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
|
|
||||||
|
|
||||||
var _fileStorePath = Path.Combine(rootPath, relativePath.Replace('/', '\\').Trim('\\'));
|
|
||||||
|
|
||||||
//_logger.LogError(rootPath);
|
|
||||||
|
|
||||||
//_logger.LogError(_fileStorePath);
|
|
||||||
|
|
||||||
var storePreviewPath = _fileStorePath + ".preview.jpg";
|
|
||||||
|
|
||||||
//if (!File.Exists(storePreviewPath))
|
|
||||||
//{
|
|
||||||
|
|
||||||
using (var image = SixLabors.ImageSharp.Image.Load(await File.ReadAllBytesAsync(_fileStorePath)))
|
|
||||||
{
|
|
||||||
image.Mutate(x => x
|
|
||||||
.Resize(1000, 1000)
|
|
||||||
);
|
|
||||||
|
|
||||||
await image.SaveAsJpegAsync(storePreviewPath);
|
|
||||||
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
|
|
||||||
return new FileContentResult(await File.ReadAllBytesAsync(storePreviewPath), "image/jpg");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上传非Dicom 文件 支持压缩包
|
/// 上传非Dicom 文件 支持压缩包
|
||||||
|
|
|
@ -19,9 +19,9 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
public class SystemNotice : Entity, IAuditUpdate, IAuditAdd
|
public class SystemNotice : Entity, IAuditUpdate, IAuditAdd
|
||||||
{
|
{
|
||||||
|
|
||||||
public List<SystemNoticeUserType> NoticeUserTypeList { get; set; }
|
public List<SystemNoticeUserType> NoticeUserTypeList { get; set; }=new List<SystemNoticeUserType>();
|
||||||
|
|
||||||
public List<SystemNoticeUserRead> NoticeUserReadList { get; set; }
|
public List<SystemNoticeUserRead> NoticeUserReadList { get; set; }=new List<SystemNoticeUserRead>();
|
||||||
|
|
||||||
public User CreateUser { get; set; }
|
public User CreateUser { get; set; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue