This is a fork from luciad/webp-imageio
org.sejda.imageio
:webp-imageio
artifact)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.
org.sejda.imageio
:webp-imageio
to your applicationWebP images can be decoded using default settings as follows.
BufferedImage image = ImageIO.read(new 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();
readParam.setBypassFiltering(true);
// Configure the input on the ImageReader
reader.setInput(new FileImageInputStream(new File("input.webp")));
// Decode the image
BufferedImage image = reader.read(0, 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 = ImageIO.read(new 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 = ImageIO.read(new File("input.png"));
// Obtain a WebP ImageWriter instance
ImageWriter writer = ImageIO.getImageWritersByMIMEType("image/webp").next();
// Configure encoding parameters
WebPWriteParam writeParam = new WebPWriteParam(writer.getLocale());
writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParam.setCompressionType(p.getCompressionTypes()[WebPWriteParam.LOSSLESS_COMPRESSION]);
// Configure the output on the ImageWriter
writer.setOutput(new FileImageOutputStream(new File("output.webp")));
// Encode
writer.write(null, new IIOImage(image, null, null), writeParam);
build
in the root of the projectcmake ..
in the 'build' directory to generate the build scripts for your system.
On Windows 64 bit run cmake -DCMAKE_GENERATOR_PLATFORM=x64 ..
to get a 64 bit dll.cmake --build . --config Release
to compile the librarybuild/src/main/c
src/main/resources/native/$platform/$bits
src/android
directorylibwebp-imageio.so
can be found under src/android/libs/<abi>
mvn clean test
in the root of the projectbuild
directorymvn release:prepare release:perform -Prelease -Darguments="-Dgpg.passphrase=secret123 -DstagingDescription=sambox"
to upload to OSS Nexus, then login and publish to Maven Central