Update: package fat jar for locally importing

This commit is contained in:
ninthakeey 2018-09-09 00:44:10 +08:00
parent d8b47baaa5
commit 89ae9edbbe
4 changed files with 63 additions and 13 deletions

View File

@ -1,12 +1,35 @@
# webp-imageio-core # webp-imageio-core
forked from qwong/j-webp forked from qwong/j-webp
Java Image I/O reader and writer for the Google WebP image format. Java Image I/O reader and writer for the Google WebP image format without system lib file.
基于[webp project of Luciad](https://bitbucket.org/luciad/webp-imageio) 0.4.2版本修改. In source program, coders need to put native lib files like .so/.dll/.dylib into the folder of `java.library.path`.
实际上只修改了`com.luciad.imageio.webp.WebP.loadNativeLibrary`这一个方法. For easier to use, qwong/j-webp (bases on [webp project of Luciad](https://bitbucket.org/luciad/webp-imageio) 0.4.2) import [native-lib-loader](https://github.com/scijava/native-lib-loader) to load native lib files from project resource folder, instead of `java.library.path`. (more details to see `com.luciad.imageio.webp.WebP.loadNativeLibrary`)
因为按他默认的加载方式, 需要把native的so/dll/dylib等文件放到OS对应的`java.library.path`对应的目录才能加载到, 这会给部署带来一些不便.
所以我们这里换成了[native-lib-loader](https://github.com/scijava/native-lib-loader)自动加载, 编译构建好的包里已经包含了各种OS上的native文件, 使用时会自动加载. However, coders pefer using jar package instead of source java code in personal project. So I fork and edit qwong/j-webp to privide a usable jar. It is a fat jar includes dependencies and native lib file (includes windows/linux/mac both 32&64bit).
具体使用方法可参看`src/main/java/example`下的源码. ## Usage
Because it is not in maven repo, so you have to put the jar file `webp-imageio-core-{version}.jar` into libs folder of your project manually.
if you use gradle, you can put it into `src/main/resource/libs`, and edit config file`build.gradle` to add local dependencies
```groovy
dependencies {
compile fileTree(dir:'src/main/resources/libs',include:['*.jar'])
}
```
if you use maven, you can put it `${project.basedir}/libs`, and edit config file `pom.xml` to add local dependencies
```xml
<dependency>
<groupId>com.github.nintha</groupId>
<artifactId>webp-imageio-core</artifactId>
<version>{versoin}</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/webp-imageio-core-{version}.jar</systemPath>
</dependency>
```
The usage of api, you can see example cases in `src/main/java/example`.

35
pom.xml
View File

@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>net.wangq</groupId> <groupId>com.github.nintha</groupId>
<artifactId>webp</artifactId> <artifactId>webp-imageio-core</artifactId>
<version>1.0-SNAPSHOT</version> <version>0.1.0</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -22,4 +22,33 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>util.Microseer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -9,8 +9,7 @@ import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
public class DecodingTest { public class DecodeTest {
public static void main(String args[]) throws IOException { public static void main(String args[]) throws IOException {
String inputWebpPath = "test_pic/test.webp"; String inputWebpPath = "test_pic/test.webp";
String outputJpgPath = "test_pic/test_.jpg"; String outputJpgPath = "test_pic/test_.jpg";

View File

@ -10,8 +10,7 @@ import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
public class EncodingTest { public class EncodeTest {
public static void main(String args[]) throws IOException { public static void main(String args[]) throws IOException {
String inputPngPath = "test_pic/test.png"; String inputPngPath = "test_pic/test.png";
String inputJpgPath = "test_pic/test.jpg"; String inputJpgPath = "test_pic/test.jpg";