Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using the shaded version of cantaloupe.jar, JBIG and JP2 images in a PDF do not render #428

Closed
cmhdave opened this issue Jan 12, 2021 · 3 comments
Labels
Milestone

Comments

@cmhdave
Copy link
Contributor

cmhdave commented Jan 12, 2021

We've found that when you have a PDF with embedded images that were encoded with JBIG or with JP2, the shaded cantaloupe.jar can't find the org.apache.pdfbox:jbig2-imageio library. Similarly we can't get jai-imageio-jpeg2000 to work in the PDFs. I am able to get them to work by adding the jars independently to the classpath on startup like so

-cp jai-imageio-core.jar:jai-imageio-jpeg2000.jar:jbig2-imageio.jar:delegate.jar:cantaloupe.jar

Attached is a PDF you can test with.
index.pdf

@cmhdave
Copy link
Contributor Author

cmhdave commented Jan 17, 2021

Adding this here on how to add plugins to a JAR

https://docs.oracle.com/javase/8/docs/technotes/guides/imageio/spec/extending.fm2.html

I just don't want to lose it. I'll take a look at how it might be done during a build process when creating the shaded jar

@cmhdave
Copy link
Contributor Author

cmhdave commented Jan 17, 2021

Ah, I understand the issue now. The jbig2-imageio library comes with a file in META-INF/services in the jar called META-INF/services/javax.imageio.spi.ImageReaderSpi but you would potentially have many of those based on the different plugins that implement that interface. Hence including multiple ImageIO plugins in a shaded JAR presents a problem.

This similar issue opened on the jai-imageio project suggests that the Maven Shade plugin should handle this but you have explicitly defined <exclude>META-INF/services/javax.imageio.*</exclude>. Were there other issues present when this wasn't explicitly excluded?

@adolski adolski added the bug label Jan 20, 2021
@adolski adolski added this to the 5.0 milestone Jan 20, 2021
@adolski
Copy link
Contributor

adolski commented Jan 20, 2021

This must have got broken in the war-to-jar switch. I don't remember why the javax.imageio.* services were being excluded. It should be fixed now, and hopefully the fix didn't break something else.

@adolski adolski closed this as completed Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants