Skip to content

Commit

Permalink
Merge pull request #5 from umjammer/0.2.5
Browse files Browse the repository at this point in the history
0.2.5
  • Loading branch information
umjammer authored Mar 6, 2024
2 parents 988f09a + bc848b8 commit 4832560
Show file tree
Hide file tree
Showing 30 changed files with 762 additions and 511 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
Expand All @@ -30,20 +34,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,8 +48,15 @@ jobs:

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +70,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
24 changes: 16 additions & 8 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: |
mvn -B package --file pom.xml
- name: Checkout repository
uses: actions/checkout@v4

- name: Check w/o SNAPSHOT when "bump version"
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build with Maven
run: mvn -B package --file pom.xml
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![Release](https://jitpack.io/v/umjammer/vavi-image-webp.svg)](https://jitpack.io/#umjammer/vavi-image-webp)
[![Java CI](https://github.com/umjammer/vavi-image-webp/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/vavi-image-webp/actions/workflows/maven.yml)
[![CodeQL](https://github.com/umjammer/vavi-image-webp/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/umjammer/vavi-image-webp/actions/workflows/codeql-analysis.yml)
![Java](https://img.shields.io/badge/Java-8-b07219)
![Java](https://img.shields.io/badge/Java-17-b07219)
[![Parent](https://img.shields.io/badge/Parent-vavi--image--sandbox-pink)](https://github.com/umjammer/vavi-image-sandbox)

# vavi-image-webp

<img src="https://upload.wikimedia.org/wikipedia/commons/0/00/WebP_logo_2010.png" width="160" />
<img src="https://upload.wikimedia.org/wikipedia/commons/0/00/WebP_logo_2010.png" width="160" /><sub>© <a href="https://developers.google.com/speed/webp">Google</a></sub>

An implementation of the VP8 image/video codec in _**pure Java**_.

Expand All @@ -19,3 +19,7 @@ https://jitpack.io/#umjammer/vavi-image-webp
```java
BufferedImage image = ImageIO.read(Paths.get("/foo/bar.webp").toFile());
```

## Reference

* [Original](https://sourceforge.net/projects/javavp8decoder/)
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
58 changes: 50 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>vavi</groupId>
<artifactId>vavi-image-webp</artifactId>
<version>0.2.4</version>
<version>0.2.5</version>

<name>Java VP8 Decoder</name>
<scm>
Expand All @@ -15,29 +15,71 @@
</issueManagement>
<description>pure Java webp Decoder</description>

<profiles>
<profile>
<id>mac arm64</id>
<activation>
<os>
<family>mac</family>
<arch>aarch64</arch>
</os>
</activation>
<properties>
<native.prefix>/opt/homebrew</native.prefix>
</properties>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
<configuration>
<source>8</source>
<target>8</target>
<encoding>UTF-8</encoding>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<version>3.2.2</version>
<configuration>
<argLine>
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
-Dvavi.test.version=${project.version}
</argLine>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>run</goal>
</goals>
<phase>integration-test</phase>
<configuration>
<target>
<java classname="Integration" fork="true">
<classpath>
<path location="${project.build.directory}/${project.artifactId}-${project.version}.jar"/>
<path refid="maven.test.classpath"/>
</classpath>
<jvmarg value="-ea" />
<arg value="${project.version}" />
</java>
</target>
<failOnError>true</failOnError>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand All @@ -53,7 +95,7 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.8.2</version>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -86,7 +128,7 @@
<dependency>
<groupId>com.github.umjammer</groupId>
<artifactId>vavi-commons</artifactId>
<version>1.1.6</version>
<version>1.1.10</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/net/sf/javavp8decoder/imageio/WebPImageReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,20 @@ private void _setInput(Object input) {
}
}

private void checkIndex(int imageIndex) {
private static void checkIndex(int imageIndex) {
if (imageIndex != 0) {
throw new IndexOutOfBoundsException("bad index");
}
}

@Override
public int getHeight(int imageIndex) throws IIOException {
checkIndex(imageIndex);
readHeader();
return height;
}

@Override
public IIOMetadata getImageMetadata(int imageIndex) throws IIOException {
if (imageIndex != 0) {
throw new IndexOutOfBoundsException("imageIndex != 0!");
Expand All @@ -95,6 +97,7 @@ public IIOMetadata getImageMetadata(int imageIndex) throws IIOException {
return metadata;
}

@Override
public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IIOException {
checkIndex(imageIndex);
readHeader();
Expand All @@ -114,30 +117,37 @@ public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IIOExce
return l.iterator();
}

@Override
public int getNumImages(boolean allowSearch) throws IIOException {
return 1; // format can only encode a single image
}

@Override
public IIOMetadata getStreamMetadata() throws IIOException {
return null;
}

@Override
public int getWidth(int imageIndex) throws IIOException {
checkIndex(imageIndex); // must throw an exception if != 0
readHeader();
return width;
}

@Override
public void imageComplete(ImageReader source) {
}

@Override
public void imageProgress(ImageReader source, float percentageDone) {
processImageProgress(percentageDone);
}

@Override
public void imageStarted(ImageReader source, int imageIndex) {
}

@Override
public BufferedImage read(int imageIndex, ImageReadParam param) throws IIOException {
super.processImageStarted(0);
readMetadata(); // Stream is positioned at start of image data
Expand All @@ -153,6 +163,7 @@ public BufferedImage read(int imageIndex, ImageReadParam param) throws IIOExcept
return dst;
}

@Override
public void readAborted(ImageReader source) {
}

Expand Down Expand Up @@ -234,34 +245,42 @@ public void readMetadata() throws IIOException {
this.metadata = new WebPMetadata();
}

@Override
public void sequenceComplete(ImageReader source) {
}

@Override
public void sequenceStarted(ImageReader source, int minIndex) {
}

@Override
public void setInput(Object input) {
super.setInput(input);
_setInput(input);
}

@Override
public void setInput(Object input, boolean isStreamable) {
super.setInput(input, isStreamable);
_setInput(input);

}

@Override
public void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata) {
super.setInput(input, seekForwardOnly, ignoreMetadata);
_setInput(input);
}

@Override
public void thumbnailComplete(ImageReader source) {
}

@Override
public void thumbnailProgress(ImageReader source, float percentageDone) {
}

@Override
public void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex) {
}
}
Loading

0 comments on commit 4832560

Please sign in to comment.