Related Article(s):
Created
February 2, 2023 10:10
-
-
Save GroupDocsGists/f83c404300f93c8e19605f58063fb2e0 to your computer and use it in GitHub Desktop.
Convert WebP to JPG, PNG, GIF, TIFF, or PDF using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert WebP image to JPG, PNG, BMP or any other format in C# | |
using (Converter converter = new Converter("path/image.webp")) | |
{ | |
ImageConvertOptions options = new ImageConvertOptions | |
{ // Set the conversion format to JPG | |
Format = ImageFileType.Jpg | |
}; | |
converter.Convert(@"path/converted-image.jpg", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert WebP to PDF in C# | |
using (Converter converter = new Converter("path/image.webp")) | |
{ | |
PdfConvertOptions options = new PdfConvertOptions(); | |
converter.Convert(@"path/converted-webp-image.pdf", options); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apply effects while converting WebP image to other formats in C# | |
using (Converter converter = new Converter("path/image.webp")) | |
{ | |
ImageConvertOptions options = new ImageConvertOptions | |
{ | |
Format = ImageFileType.Jpg, | |
Grayscale = true, // Convert the image in Grayscale | |
Height = 141, // Resize the Image Height | |
Width = 167, // Resize the image Width | |
FlipMode = ImageFlipModes.FlipX, // Flip the image | |
Contrast = 50, // Change the contrast of image | |
RotateAngle = 90, // Rotate the image | |
Brightness = 50, // Change the brightness | |
Gamma = 0.5F, // Gamma Setting | |
Watermark = // Watermark Settings | |
{ | |
Text = "GroupDocs", | |
Width = 100, | |
Height = 100, | |
Background = false, | |
Top = 70, | |
Left = 90, | |
RotationAngle = -45, | |
} | |
}; | |
converter.Convert(@"path/converted-with-options.jpg", options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment