C#.NET 4.8 WEBP 转 GIF
项目是.NET 4.8。
nuget 引用 Magick.NET-Q16-AnyCPU ,版本:7.14.5。高版本,如:12.2 已经不支持.NET FRAMEWORK了。
using ImageMagick; using System; using System.IO; using System.Windows.Forms; namespace WebpToGif { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { try { string webpFullName = Path.Combine(Application.StartupPath, "二手的三星s20.webp"); string gifFullName = Path.Combine(Application.StartupPath, "二手的三星s20.gif"); WebpToGif(webpFullName, gifFullName); MessageBox.Show("OK"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } public void WebpToGif(string webpFullName,string gifFullName) { //webp 转 GIF using (var animatedWebP = new MagickImageCollection(webpFullName)) { animatedWebP.Write(gifFullName, MagickFormat.Gif); } ////GIF 转 webp //using (var animatedGif = new MagickImageCollection("animated.gif")) //{ // animatedGif.Write("animated-generated.webp", MagickFormat.WebP); //} } } }
OK