Convert WebP to PNG using java

Webp is Google's image format, which is not supported by the Java class library imageio. At present, in addition to online conversion and tools, the third-party class library conversion webp format roughly includes:

1. Linux: Google libwebp is not only a class library, but also can be called on 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 Verify availability (under linux environment)

This article describes the third method:

In Linux environment, Google libwebp-0.4 0 into the root directory of luciad-webp-imageio-2962dd563583, install cmake, and execute cmake in the above root directory Command. After cmake is completed, execute the make command under the above root directory. Make will be generated in Java directory and c Directory respectively Jar and So file. Will Jar to import its own java project path The so file is placed in the Java path of the system. At this point, you can read and write webp format files using imageio in a java project.

explain:

Operating environment: Ubuntu

Language: Java

Example: webp to png

Steps:

1: 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

Considering that the above resources need to be downloaded over the wall, it is relatively slow. I have transferred three files to CSDN, 0 points to download.

Address: http://download.csdn.net/detail/geeklei/8161731

2: Compile webp imageio Jar and libwebp imageio so

1. Unzip luciad webp imageio-2962dd563583 zip。

2. Libwebp-0.4 0.tar. Unzip GZ to the root directory of luciad-webp-imageio-2962dd563583.

3. Add cmake-3.1 0-rc2-Linux-i386. Tar decompression. Extract cmake and use it immediately. Of course, you can also download and install it from the image source with your own command.

4. On the premise that cmake is available, execute cmake in the root directory of luciad-webp-imageio-2962dd563583 Command. Pay attention to cmake and There is a space between

5. Cmake ends, you see the makefile file, and execute the make command in the root directory of luciad-webp-imageio-2962dd563583.

6. After making, you can see it in the Java and C folders under the root directory of luciad-webp-imageio-2962dd563583 Jar and so

III:

1. Webp imageio Jar is imported into your own java project in eclipse.

2. Libwebp imageio Put so into the Java path of the system. You can reuse system. Net in your project out. println(System.getProperty("java.library.path")); Statement to print out the Java path to avoid omission. There are multiple printed Java paths, some of which are repeated.

3. Use imageio in the project to read and write webp format files.

code:

Thank luciad, author of luciad / webp imageio project, for his efforts and selfless help to my questions.

This morning, I found that someone had transferred the compiled package to the project.. I didn't test it either, but share the bag. Original address: https://bitbucket.org/luciad/webp-imageio/downloads

CSDN address: http://download.csdn.net/detail/geeklei/8163329

It's in there jar . so . dll

It covers Linux 32 / 64, Windows 32 / 64 and other versions

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>