Java Image I/O reader and writer for the Google WebP image format.


webp-imageio is distributed under the Apache Software License version 2.0.


  • Add webp-imageio.jar to the classpath of your application
  • Ensure, libwebp-imageio.dylib or webp-imageio.dll is accessible on the Java native library path (java.library.path system property)
  • The WebP reader and writer can be used like any other Image I/O reader and writer.


WebP images can be decoded using default settings as follows.

BufferedImage image = File("input.webp"));

To customize the WebP decoder settings you need to create instances of ImageReader and WebPReadParam.

// Obtain a WebP ImageReader instance
ImageReader reader = ImageIO.getImageReadersByMIMEType("image/webp").next();

// Configure decoding parameters
WebPReadParam readParam = new WebPReadParam();

// Configure the input on the ImageReader
reader.setInput(new FileImageInputStream(new File("input.webp")));

// Decode the image
BufferedImage image =, readParam);


Encoding is done in a similar way to decoding.

You can either use the Image I/O convenience methods to encode using default settings.

// Obtain an image to encode from somewhere
BufferedImage image = File("input.png"));

// Encode it as webp using default settings
ImageIO.write(image, "webp", new File("output.webp"));

Or you can create an instance of ImageWriter and WebPWriteParam to use custom settings.

// Obtain an image to encode from somewhere
BufferedImage image = File("input.png"));

// Obtain a WebP ImageWriter instance
ImageWriter writer = ImageIO.getImageWritersByMIMEType("image/webp").next();

// Configure encoding parameters
WebPWriteParam writeParam = new WebPWriteParam(writer.getLocale());

// Configure the output on the ImageWriter
writer.setOutput(new FileImageOutputStream(new File("output.webp")));

// Encode
writer.write(null, new IIOImage(image, null, null), writeParam);


Compiling the native library for Java SE

  • Install CMake 2.8 or newer. CMake can be downloaded from or installed using your systems package manager.
  • Create a directory called build in the root of the project
  • Open a terminal and navigate to the newly created 'build' directory
  • Run cmake .. in the 'build' directory to generate the build scripts for your system.
  • cmake --build . to compile the library
  • The compiled library can be found under the directory build/src/main/c

Compiling the native library for Android

  • Install the Android NDK.
  • Run ndk-build in the src/android directory
  • After completion can be found under src/android/libs/<abi>

Compiling the Java library

Using Gradle

  • Run ./gradlew build -x test in the root of the project
  • The compiled Java library can be found under the build directory