Jea*_* AR 4 c# image-compression asp.net-core
有谁知道如何在 c# asp.net core 中压缩任何类型(jpg、png、gif 等)的图像。WebP 在核心上不起作用。我下载了 ImageProcessor Core 库,但不知道如何压缩/降低图像质量。这是我们尝试过的,但没有奏效。
newImage.Quality = old_image.Quality-20;
newImage.HorizontalResolution = 0;
newImage.VerticalResolution = 0;
Run Code Online (Sandbox Code Playgroud)
lil*_*cob 13
我们使用Magic.Net来压缩 jpeg、gif 和 png 图像。它支持 .Net Core,可通过Nuget 获得。
例子:
var file = new FileInfo(fileName);
Console.WriteLine("Bytes before: " + file.Length);
var optimizer = new ImageOptimizer();
optimizer.Compress(file);
file.Refresh();
Console.WriteLine("Bytes after: " + file.Length);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18119 次 |
| 最近记录: |