sksamuel / scrimage

JVM - Java, Kotlin, Scala image processing library
https://sksamuel.github.io/scrimage
Apache License 2.0
1.07k stars 140 forks source link

WebP parsing is broken on latest version #265

Closed rzam closed 1 year ago

rzam commented 1 year ago

After upgrading from version 4.0.33 to 4.0.34, the parsing of WebP files seems to be broken.

Gradle:

dependencies {
    implementation("com.sksamuel.scrimage:scrimage-core:4.0.34")
    implementation("com.sksamuel.scrimage:scrimage-webp:4.0.34")
}

Code:

public static void main(String[] args) throws IOException {
    ImmutableImage image = ImmutableImage.loader().fromFile(new File("example.webp"));
    System.out.println(image.width);
}

Result:

Exception in thread "main" java.util.ServiceConfigurationError: com.sksamuel.scrimage.nio.ImageReader: Provider com.sksamuel.scrimage.webp.WebpImageReader could not be instantiated
[...]
    at com.sksamuel.scrimage.nio.ImageReaders.detectReaders(ImageReaders.java:26)
    at com.sksamuel.scrimage.nio.ImageReaders.detectReaders(ImageReaders.java:22)
    at com.sksamuel.scrimage.nio.ImageReaders.<clinit>(ImageReaders.java:19)
    at com.sksamuel.scrimage.nio.ImmutableImageLoader.load(ImmutableImageLoader.java:137)
    at com.sksamuel.scrimage.nio.ImmutableImageLoader.fromFile(ImmutableImageLoader.java:104)
Caused by: java.lang.ExceptionInInitializerError
    at com.sksamuel.scrimage.webp.WebpImageReader.<init>(WebpImageReader.java:11)
[...]
Caused by: java.lang.RuntimeException: java.io.IOException: Could not locate webp binary at [/webp_binaries/dwebp, /webp_binaries/window/dwebp, /webp_binaries/windows/dwebp, /dist_webp_binaries/libwebp-1.3.0-windows-x64/bin/dwebp]
    at com.sksamuel.scrimage.webp.DWebpHandler.<clinit>(DWebpHandler.java:20)
[...]
Caused by: java.io.IOException: Could not locate webp binary at [/webp_binaries/dwebp, /webp_binaries/window/dwebp, /webp_binaries/windows/dwebp, /dist_webp_binaries/libwebp-1.3.0-windows-x64/bin/dwebp]
    at com.sksamuel.scrimage.webp.WebpHandler.installBinary(WebpHandler.java:40)
    at com.sksamuel.scrimage.webp.DWebpHandler.installDWebp(DWebpHandler.java:35)
    at com.sksamuel.scrimage.webp.DWebpHandler.<clinit>(DWebpHandler.java:18)

The same code works as expected on version 4.0.33.

Tested on Windows using OpenJDK8/11/17 and GraalVM17.

BreninSul commented 1 year ago

The same problem on windows

sksamuel commented 1 year ago

Fixed in 4.0.36