In our previous post, we discussed WebP images and learned to convert WebP Images in Java. Today, in this article, we will learn to programmatically convert the WebP images into JPG, PNG, TIFF, and other formats using C#.

Convert WebP image to JPG, PNG or PDF formats in CSharp

First, we will have a look to convert the WebP images in the simplest way. Later we will convert with some customized options like tilt, flip, grayscale, resize, change gamma, contrast, and brightness, and add watermark to converted JPG images. Following are the quick links to topics:

Steps in this article and code samples are using GroupDocs.Conversion for .NET and the following WebP Image. So please make sure to install the API from any of the following methods:

  • Install using NuGet Package Manager.
  • Download the DLL and reference it into the project.
WebP Image

WebP Image

Convert WebP to JPG in C#

To convert the WebP images into other formats, use the Converter class. For the simple conversion, you can use the below-mentioned few lines of C# code. This example shows the quick conversion of a WebP image to a JPG file. Just follow the steps:

  1. Instantiate the Converter object with the source WebP image.
  2. Instantiate the Image Conversion Options using ImageConvertOptions class and just set the Format to JPG.
  3. Call the Convert method with the output file path and the conversion options.

Here is the converted JPG image that is converted from WebP format using the above code:

Converted from WebP to JPG

Converted JPG Image

Convert WebP to PNG, TIFF and other Image Formats in C#

Using the same above code and by just changing the file format i.e. “ImageFileType.Jpg” and the output file name, you may easily convert your WebP files into JPEG, PNG, TIF, TIFF, BMP, etc.

This was the simple conversion, now let us convert with different effects.

Convert WebP to JPG, PNG, TIFF with Advanced Options in C#

Along with the conversion of WebP to other formats, we can also add effects while converting. Below are some of the effects like; convert to grayscale; flip images horizontally or vertically; rotate the image to any angle; resize the image to make it smaller or larger; change the contrast, brightness, gamma values; or even apply watermarks to the converted images.

Converted from WebP to JPG - Change Contrast, Flip, Watermark, Brightness, Resize, Gamma, Grayscale, Rotate

Converted WebP Image to JPG: Contrast - Flip - Watermark - Brightness - Resize - Gamma - Grayscale - Rotate

Here is the code that is used to apply these effects. You may apply these effects one by one or in combination to get the desired results.

Convert WebP to PDF in C#

Along with the conversion of WebP images to other image file formats, we can also convert images to PDF format. Following 3 lines of code will do the trick and help you converting the WebP image to PDF format.

For more details and advance options to convert into PDF, you may visit the documentation.

See Also

There are many other open-source examples that are publicly available at GitHub Repository. Download the source code and quickly run the examples using the getting started guide. In case of any difficulty, look at the documentation or reach us at any time on the forum.