WEBP is the image format of Google, Java class Library ImageIO is not supported in this format. Currently, in addition to the online conversion and tools, the third-party class library conversion WEBP format is roughly:
1.linux:google LIBWEBP is both a class library and can be called at the command line
2.python:python Image Library (PIL) and its branches Https://pypi.python.org/pypi/PIL I don't know much.
3.java:luciad/webp-imageio HTTPS://BITBUCKET.ORG/LUCIAD/WEBP-IMAGEIO/SRC confirmed available (Linux environment)
This article describes the third method:
In the Linux environment, put Google libwebp-0.4.0 in the luciad-webp-imageio-2962dd563583 root directory, install CMake, in the above root directory to perform cmake. Command, execute the make command under the above root directory when the CMake is complete. Make completion generates. jar and. So files, respectively, in the Java directory and C directory. Import the. jar into your Java project path and put the. so file to the system Java path. The WEBP format file can be read and written using ImageIO in the Java project at this time.
Description
Operating Environment: Ubuntu
Language: Java
Example: WEBP to PNG
Steps:
One: Download the following three packages
1.CMake installation package: Cmake-3.1.0-rc2-linux-i386.tar
2.Google webp Dependency Library: libwebp-0.4.0.tar.gz Original address: Https://developers.google.com/speed/webp/download?hl=zh-cN
3.luciad/webp-imageio Project: Luciad-webp-imageio-2962dd563583.zip Original address: HTTPS://BITBUCKET.ORG/LUCIAD/WEBP-IMAGEIO/SRC
Consider that the above resources need to flip the wall to download, relatively slow. I have transferred three files to csdn,0 for download.
Address: http://download.csdn.net/detail/geeklei/8161731
Two: Compile to get Webp-imageio.jar and libwebp-imageio.so
1. Unzip the luciad-webp-imageio-2962dd563583.zip.
2. Extract the libwebp-0.4.0.tar.gz to the luciad-webp-imageio-2962dd563583 root directory.
3. Unzip the Cmake-3.1.0-rc2-linux-i386.tar. CMake decompression is available, of course, you can also use the command to download the installation from the image source.
4. Under luciad-webp-imageio-2962dd563583 root directory, perform cmake under the premise that CMake is available. Command. Pay attention to CMake and. There is a space between
5.cmake end, see the makefile file, execute the Make command under the luciad-webp-imageio-2962dd563583 root directory.
At the end of 6.make, you can see the. jar and. So in the Java and C folders in the luciad-webp-imageio-2962dd563583 root directory.
Three:
1. Import the Webp-imageio.jar into your own Java project in Eclipse.
2. Place the libwebp-imageio.so in the system Java path. The System.out.println (System.getproperty ("Java.library.path")) can be used in the project, and the statement prints out the Java path to avoid omission. The printed Java path has multiple, partially duplicated.
3. You can read and write WEBP format files using ImageIO in your project.
Code:
File file1= New file ("/home/geeklei/desktop/640_tp.webp"); File file2= New file ("/home/geeklei/desktop/640a.png"); System.out.println (System.getproperty ("Java.library.path")); try {BufferedImage im = Imageio.read (file1); Imageio.write (IM, "png", file2);} catch (IOException e) {e.printstacktrace ();}
Thanks to the efforts of Luciad/webp-imageio project author Luciad and the selfless help of my questions.
Convert WebP to PNG using Java