Skip to content

Commit

Permalink
Update: package fat jar for locally importing
Browse files Browse the repository at this point in the history
  • Loading branch information
nintha committed Sep 8, 2018
1 parent d8b47ba commit 89ae9ed
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 13 deletions.
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
# webp-imageio-core
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`这一个方法.
因为按他默认的加载方式, 需要把native的so/dll/dylib等文件放到OS对应的`java.library.path`对应的目录才能加载到, 这会给部署带来一些不便.
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-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 changes: 32 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
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>

<groupId>net.wangq</groupId>
<artifactId>webp</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>com.github.nintha</groupId>
<artifactId>webp-imageio-core</artifactId>
<version>0.1.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -22,4 +22,33 @@
</dependency>
</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>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import java.io.File;
import java.io.IOException;

public class DecodingTest {

public class DecodeTest {
public static void main(String args[]) throws IOException {
String inputWebpPath = "test_pic/test.webp";
String outputJpgPath = "test_pic/test_.jpg";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
import java.io.File;
import java.io.IOException;

public class EncodingTest {

public class EncodeTest {
public static void main(String args[]) throws IOException {
String inputPngPath = "test_pic/test.png";
String inputJpgPath = "test_pic/test.jpg";
Expand Down

0 comments on commit 89ae9ed

Please sign in to comment.