Sparkdo.Imaging.AspNetCore
1.0.1
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Sparkdo.Imaging.AspNetCore --version 1.0.1
NuGet\Install-Package Sparkdo.Imaging.AspNetCore -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sparkdo.Imaging.AspNetCore" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sparkdo.Imaging.AspNetCore" Version="1.0.1" />
<PackageReference Include="Sparkdo.Imaging.AspNetCore" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sparkdo.Imaging.AspNetCore --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sparkdo.Imaging.AspNetCore, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sparkdo.Imaging.AspNetCore@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sparkdo.Imaging.AspNetCore&version=1.0.1
#tool nuget:?package=Sparkdo.Imaging.AspNetCore&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sparkdo.Imaging.AspNetCore
Sparkdo 图像处理 ASP.NET Core 集成库,提供图像压缩和调整大小功能的 ASP.NET Core 特性实现。
功能特性
- ASP.NET Core ActionFilter 特性实现
- 自动图像压缩功能
- 自动图像尺寸调整功能
- 支持多种图像输入格式(IFormFile、IRemoteStreamContent、Stream、byte[])
- 与 Sparkdo 图像处理抽象库无缝集成
- 与 ASP.NET Core 依赖注入系统集成
安装
<PackageReference Include="Sparkdo.Imaging.AspNetCore" Version="x.x.x" />
核心组件
CompressImageAttribute
图像压缩特性,用于在控制器操作执行前后自动压缩图像:
- 自动检测并压缩图像参数
- 支持 IFormFile、IRemoteStreamContent、Stream、byte[] 类型
- 保持非图像参数不变
- 与 ASP.NET Core 模型绑定集成
使用示例:
[HttpPost]
[CompressImage("imageFile")]
public async Task<IActionResult> UploadImage(IFormFile imageFile)
{
// imageFile 将自动被压缩
}
ResizeImageAttribute
图像调整大小特性,用于在控制器操作执行前后自动调整图像尺寸:
- 自动检测并调整图像参数尺寸
- 支持指定宽度、高度或统一尺寸
- 支持多种调整模式
- 支持 IFormFile、IRemoteStreamContent、Stream、byte[] 类型
- 保持非图像参数不变
使用示例:
[HttpPost]
[ResizeImage(800, 600, "imageFile")]
public async Task<IActionResult> UploadImage(IFormFile imageFile)
{
// imageFile 将自动调整为 800x600 尺寸
}
扩展性
该库提供了完整的 ASP.NET Core 图像处理集成实现,可以通过以下方式扩展:
- 实现自定义的
IImageCompressorContributor来添加特定格式的图像压缩功能 - 实现自定义的
IImageResizerContributor来添加特定格式的图像尺寸调整功能 - 通过依赖注入注册自定义的贡献者实现
代码结构说明
本项目包含以下主要组件:
特性实现
CompressImageAttribute: 图像压缩特性ResizeImageAttribute: 图像调整大小特性
模块配置
SparkdoImagingAspNetCoreModule: 图像处理 ASP.NET Core 模块配置
所有公共接口和类都添加了详细的 XML 文档注释,便于开发者理解和使用。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- JetBrains.Annotations (>= 2025.2.2)
- Microsoft.Extensions.DependencyModel (>= 10.0.0)
- Nito.AsyncEx.Context (>= 5.1.2)
- Sparkdo.Imaging.Abstractions (>= 1.0.1)
- System.Linq.Dynamic.Core (>= 1.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.2-preview.4 | 53 | 2/8/2026 |
| 1.0.2-preview.3 | 53 | 2/1/2026 |
| 1.0.2-preview.2 | 58 | 1/31/2026 |
| 1.0.2-preview.1 | 174 | 12/4/2025 |
| 1.0.1 | 214 | 11/27/2025 |
| 1.0.0 | 203 | 11/25/2025 |