C# ImageProcessor在I';我正在尝试将图像转换为webp

C# ImageProcessor在I';我正在尝试将图像转换为webp,c#,asp.net-core,image-processing,webp,C#,Asp.net Core,Image Processing,Webp,通过阅读本文,我正在学习如何将图像转换为.webp。 以下是我的代码,用于执行此操作: public IActionResult ConvertImage(格式文件) { var webpFullFilePath=Path.Combine(_webHostEnvironment.WebRootPath,“imagename.webp”); 使用(var webPFileStream=newfilestream(webpFullFilePath,FileMode.Create)) { 使用(Ima

通过阅读本文,我正在学习如何将图像转换为.webp。 以下是我的代码,用于执行此操作:

public IActionResult ConvertImage(格式文件)
{
var webpFullFilePath=Path.Combine(_webHostEnvironment.WebRootPath,“imagename.webp”);
使用(var webPFileStream=newfilestream(webpFullFilePath,FileMode.Create))
{
使用(ImageFactory ImageFactory=new ImageFactory(preserveExifData:false))
{
imageFactory.Load(file.OpenReadStream())//在此处抛出错误
.Format(新的WebPFormat())
.品质(100)
.Save(webPFileStream);
}
}
}
但当我上传图像时,它会引发一个异常:

System.TypeInitializationException:“ImageProcessor.Plugins.WebP.Imaging.Formats.NativeMethods”的类型初始值设定项引发异常。 --->System.IO.IOException:文件“/home/alex/Documents/sayzim/api/bin/Debug/netcoreapp3.1/ImageProcessor.dll”已存在。 位于System.IO.FileSystem.CreateDirectory(字符串完整路径) 在System.IO.DirectoryInfo.Create()中 在ImageProcessor.Configuration.NativeBinaryFactory.c__显示Class7_0.b_0(字符串b) 在System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey键,Func
2值工厂) 在ImageProcessor.Configuration.NativeBinaryFactory.RegisterNativeBinaryBinary(字符串名称,字节[]resourceBytes) 在ImageProcessor.Plugins.WebP.Imaging.Formats.NativeMethods..cctor()上 ---内部异常堆栈跟踪的结束---

以下是我正在使用的软件包:

  • 如何解决这个问题?如果您知道将图像转换为.webp的其他方法,请与我共享:)


    p.S.我使用linux mint。

    你能解决它吗?@Jay不记得了,但现在我转到ImageSharp和SkiaSharp,没有问题了