sksamuel / scrimage

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

Unable to Read JPEG Files #284

Closed homestar9 closed 4 weeks ago

homestar9 commented 5 months ago

Hello, I am working on building a CFML wrapper for your awesome library so the ColdFusion community can use it. I added the following JARs to my application's classPath:

scrimage-core-4.1.1.jar scrimage-webp-4.1.1.jar

However, when I attempt to read a JPEG image, I get the following error: Image parsing failed for JPEG. If the format is webp ensure you have a webp reader on your classpath, such as the scrimage-webp module. Tried the following ImageReader implementations:

My code looks like this:

// Get a new instance of the immutable image object (com.sksamuel.scrimage.ImmutableImage)
var immutableImage = scrimage.getImmutableImage();

// Create a new instance of a java file object pointing to a sample jpg file
var imgFile = createObject("java", "java.io.File").init( "D:\temp\test.jpg" );

// read the java file object
var myImage = immutableImage.loader().fromFile( imgFile );

Do you have any idea of what I might be missing?

sksamuel commented 5 months ago

Sounds like the scrimage-webp maven module is not being picked up from the classpath that coldfusion uses.

homestar9 commented 5 months ago

Strange. I do see scrimage-webp.jar listed in all of the jars loaded. I wonder if it could have something to do with the JVM version used by Adobe ColdFusion. Thanks for taking the time to reply by the way. :)

dimitriz09 commented 5 months ago

Hello, i do have a very similar problem. While it works well running locally on my PC, on my preprod env i have this error.

If the format is `webp` ensure you have a webp reader on your classpath, such as the `scrimage-webp` module. Tried the following ImageReader implementations:
com.sksamuel.scrimage.webp.WebpImageReader@301c39b1 failed due to java.io.IOExceptio

I use docker to run a jar file on a VPS. When inspecting the jar deployed (built with command gradle buildFatJar) i can see that the file com/sksamuel/scrimage/webp/WebpImageReader.class is indeed in the jar file so i don't really understand the error.

aaa1115910 commented 1 month ago

I also encountered the same problem. When I package the jar and then run it, the problem will occur.

image

~update: It seems that an exception will be thrown when reading any image.... not only jpg....~

Solution found in #245

sksamuel commented 4 weeks ago

Solution in #245