Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9703

C# でWebPを読み書きする

$
0
0
画像処理などで使う画像をWebPに変換して容量減らせればいいなーと思ってやり方を調べたので 備忘録的に書いておきます。 Nugetで「ImageProcessor」パッケージをインストールする Visual Studio 2022 .Net Framework 4.8で動作を確認しています。 他の環境は未チェックですのであしからず。 WebPから、jpegやpng等に変換して保存する public static void Save(string inPutPath, string outPutPath, ImageFormat format) { var wf = new WebPFormat(); using (var image = (Bitmap)wf.Load(new FileStream(inPutPath, FileMode.Open, FileAccess.Read))) { image.Save(outPutPath, format); } } jpegやpng等から、WebPに変換して保存する Taskで並列に変換&保存できてるっぽいけど、すぐにCPU使用率が100%になる… public static void SaveWebP(string inPutPath, string outPutPath) { var wf = new WebPFormat(); using (var image = new Bitmap(inPutPath)) { wf.Save(outPutPath, image, 0); } }

Viewing all articles
Browse latest Browse all 9703

Trending Articles