3

Anyone know if it's possible to convert a Bitmap to a WebP image using C#?

Been Google-ing around but wasn't able to find anything for C#. I found this: mc-kay/libwebp-sharp · GitHub but it doesn't seem to convert bitmaps to the WebP format.

Any ideas?

Picrofo Software
  • 5,417
  • 3
  • 21
  • 37
Joey Morani
  • 23,675
  • 32
  • 81
  • 128

1 Answers1

4

Load a WebP image

using (Bitmap image = WebPFormat.LoadFromStream(new FileStream("image.webp", FileMode.Open, FileAccess.Read)))
{
    image.Save("image.png", ImageFormat.Png);
}

Save a WebP image

using (Image image = Image.FromFile("image.jpg"))
{
    Bitmap bitmap = new Bitmap(image);
    WebPFormat.SaveToFile("image.webp", bitmap);
}

For more info take a look here webp

Anton Baksheiev
  • 2,181
  • 2
  • 13
  • 14
  • Thanks. Do you know a way I can speed it up? At the moment it's quite slow at converting them to the WebP format. Or is there a way I can directly capture the screen in the WebP format without having to convert it? Thanks again. – Joey Morani Nov 04 '12 at 23:22
  • The Link is dead – TaW Apr 09 '22 at 10:06