Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Created January 20, 2021 07:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save GroupDocsGists/6bfdc6033f28598a78631ccadf843c3c to your computer and use it in GitHub Desktop.
Save GroupDocsGists/6bfdc6033f28598a78631ccadf843c3c to your computer and use it in GitHub Desktop.
Convert WebP to JPG, PNG, GIF, TIFF, or PDF in Java
// Convert WebP to JPG in Java using GroupDocs.Conversion API
Converter converter = new Converter("filePath/WebPImage.webp");
ImageConvertOptions options = new ImageConvertOptions();
options.setFormat(ImageFileType.Jpg);
converter.convert("path/WebPToJPG.jpg", options);
// Convert WebP to PDF in Java using GroupDocs.Conversion API
Converter converter = new Converter("filePath/WebPImage.webp");
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("filePath/WebPToPDF.pdf", options);
// Convert WebP to JPG, PNG, GIF, TIFF in Java and apply filters like Flip, Brightness, Contrast, Gamma, Rotate, Watermark
Converter converter = new Converter("filePath/WebPImage.webp");
// Set Image Conversion Options. You can apply one filter at a time.
ImageConvertOptions options = new ImageConvertOptions();
options.setFormat(ImageFileType.Jpg);
options.setFlipMode(ImageFlipModes.FlipX);
options.setBrightness(50);
options.setContrast(50);
options.setGamma(0.5F);
options.setGrayscale(true);
options.setRotateAngle(90);
// Set Watermark Text and Appearance
WatermarkOptions watermark = new WatermarkOptions();
watermark.setText("GroupDocs");
watermark.setFont(new Font("Arial", Font.BOLD, 130));
watermark.setColor(Color.WHITE);
watermark.setBackground(false);
watermark.setRotationAngle(-45);
watermark.setTop(70);
watermark.setLeft(150);
watermark.setTransparency(0.2);
options.setWatermark(watermark);
converter.convert("filePath/WebPToJPG.jpg", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment