Giter Site home page Giter Site logo

webp-imageio's Introduction

Travis build status

Forked repository

This is a fork from luciad/webp-imageio

Changes

  • Native libs are bundled in the jar
  • Published to Maven Central (org.sejda.imageio:webp-imageio artifact)
  • Android support unknown (have not tested)

Supported platforms

  • windows (32, 64 bit)
  • linux (64 bit)
  • mac (64 bit)

Description

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

License

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

Usage

  • Add Maven dependency org.sejda.imageio:webp-imageio to your application
  • The WebP reader and writer can be used like any other Image I/O reader and writer.

Decoding

WebP 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

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);

Compiling

Compiling the native library for Java SE

  • Install CMake 2.8 or newer. CMake can be downloaded from www.cmake.org or installed using your systems package manager.
  • Install VS 2017 Community and make sure the C++/Cmake dev tools modules are installed
  • 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. On Windows 64 bit run cmake -DCMAKE_GENERATOR_PLATFORM=x64 .. to get a 64 bit dll.
  • cmake --build . --config Release to compile the library
  • The compiled library can be found under the directory build/src/main/c
  • Copy the compiled library to src/main/resources/native/$platform/$bits

Compiling the native library for Android

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

Compiling the Java library

Using Maven

  • Run mvn clean test in the root of the project
  • The compiled Java library can be found under the build directory
  • Run mvn release:prepare release:perform -Prelease -Darguments="-Dgpg.passphrase=secret123 -DstagingDescription=sambox" to upload to OSS Nexus, then login and publish to Maven Central

webp-imageio's People

Contributors

ediweissmann avatar pepijnve avatar years-enron avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.