If you have a large collection of images in WebP format, converting them to JPG in bulk can be a game-changer. WebP, developed by Google, is known for its efficient compression and high quality. However, it often faces compatibility issues with various technologies.
This can be particularly challenging for Java developers who need to integrate WebP images into their applications. Converting these images to JPG ensures broader compatibility and smoother integration.
In this article, I’ll guide you through the process of using Java to convert WebP files to JPG format with JDeli, ensuring your images are accessible.
Mass convert WebP to JPG using Java
- Download the JDeli trial jar.
- Process image if needed (scale, sharpen, lighten, watermark, etc)
- Write out BufferedImage as JPG image file
BufferedImage bufferedImage = JDeli.read(new File("webpImageFile.webp"));
// Read WebP image into Java
bufferedImage = operations.apply(BufferedImage bufferedImage);
// Process image (Optional)
JDeli.write(bufferedImage, "jpg", new File("jpgImageFile.jpg"));
// Write out BufferedImage as JPEG image file
Export WebP to JPG in one line of code
With the JDeli.convert()
method you can save Webp as JPG in just one line of code.
Using File
JDeli.convert(File inFile, File outFile);
Using InputStream and OutputStream
JDeli.convert(InputStream inputStream, OutputStream outputStream, "jpg");
Using byte[]
byte[] outputData = JDeli.convert(byte[] inputData, "jpg");
Configure Output Settings
Specify an EncoderOptions object with this option to configure output settings, including image compression.
JDeli.convert(File inFile, EncoderOptions outputOptions, File outfile);
How to bulk convert WebP to JPG from the command line
Mass convert WebP to JPG using command line or bash, bat, and PowerShell scripts. This method also enables JDeli to be invoked from any programming language that supports creating a child process.
java -jar jdeli.jar –convert jpg "inputFileOrDir" "outputDir"
In this tutorial you learned how to convert WebP to JPG in bulk, you can also have a look at our tutorials for more format conversions.
Are you a Java Developer working with Image files?
// Read an image
BufferedImage bufferedImage = JDeli.read(dicomImageFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(heicImageFile);
// Write an image
JDeli.write(bufferedImage, "heic", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(jpegImageFile);
// Write an image
JDeli.write(bufferedImage, "jpeg", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(jpeg2000ImageFile);
// Write an image
JDeli.write(bufferedImage, "jpx", outputStreamOrFile);
// Write an image
JDeli.write(bufferedImage, "pdf", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(pngImageFile);
// Write an image
JDeli.write(bufferedImage, "png", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(tiffImageFile);
// Write an image
JDeli.write(bufferedImage, "tiff", outputStreamOrFile);
// Read an image
BufferedImage bufferedImage = JDeli.read(webpImageFile);
// Write an image
JDeli.write(bufferedImage, "webp", outputStreamOrFile);
Why do developers choose JDeli over free alternatives?
- Works with newer image formats such as AVIF, HEIC, JPEG XL, WEBP
- Better support than alternatives for JPEG, PNG, TIFF.
- Prevent JVM crashes caused by native code in other image libraries
- Better performance than other popular Java image libraries