Beginner questions: displaying tiff not successfull with imageio-jpeg; metadata in JPEG not read.
See original GitHub issueSorry: I could not find a forum, mailing list or something alike. As I do think these are beginner questions and not bugs, I put 2 in one post thereby only “abusing” one post instead of two.
I just started using the TwelveMonkeys imageIO library, using the 3.6 version, and have 2 issues.
Not being able to display tiff when using imageio-jpeg. In my project in my build.gradle.kts I have the following:
// Twelve monkeys imageio (supports bmp, jpeg, jpeg-2000, PNM (PBM/PGM/PPM/PAM), PSD, TIFF, HDR, IFF, PCX
// PICT, SGI, TGA, ICNS, ICO & CUR, SVG, WMF)
implementation("com.twelvemonkeys.imageio:imageio-core:3.6")
implementation("com.twelvemonkeys.imageio:imageio-metadata:3.6")
//
implementation("com.twelvemonkeys.imageio:imageio-jpeg:3.6")
//
implementation("com.twelvemonkeys.imageio:imageio-tiff:3.6")
//implementation("com.twelvemonkeys.imageio:imageio-psd:3.6")
implementation("com.twelvemonkeys.imageio:imageio-pnm:3.6")
implementation("com.twelvemonkeys.imageio:imageio-pcx:3.6")
implementation("com.twelvemonkeys.imageio:imageio-sgi:3.6")
implementation("com.twelvemonkeys.imageio:imageio-tga:3.6")
implementation("com.twelvemonkeys.imageio:imageio-icns:3.6")
implementation("com.twelvemonkeys.imageio:imageio-hdr:3.6")
My java project reads images and creates previews of them. When using the imageio-jpeg
no tiff previews are created and when opening them from my app in a (fullscreen) jframe I do get a java.lang.NullPointerException
. Somehow the new ImageIcon
, with or without resizing, is no longer working for tiffs with imageio-jpeg
enabled.
When disabling the imageio-jpeg
in my build.gradle.kts, I do see tiff previews and I am able to display tiff images full screen.
Is this a bug or some beginner mistake?
Reading metadata in jpegs does not work I thought that EXIFReader is deprecated and that TIFFReader should be used for all images when reading metadata.
So I created a new test method in my project and did
try {
Directory metadata = new TIFFReader().read(new FileImageInputStream(file));
for (Entry entry: metadata) {
//logger.info("identifier {} fieldname {} value {} valueString {}, typename {}", entry.getIdentifier(), entry.getFieldName(), entry.getValue(), entry.getValueAsString(), entry.getTypeName());
logger.info("fieldname {} value {}", entry.getFieldName(), entry.getValue());
}
} catch (IOException e) {
e.printStackTrace();
}
When I used this on tiff images it works great.
When using on jpg’s I get:
javax.imageio.IIOException: Invalid TIFF byte order mark '��', expected: 'II' or 'MM'
This is happening on all jpegs from multiple cameras and sources. I fully understand that it is my fault, but I could not find how to get my metadata from my jpegs?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
The fact that you don’t have all the iff/pcx/pict/pnm/sgi/tga formats available and only either the TIFF or the JPEG plugin (only the TwelveMonkeys JPEG plugin supports jpeg-lossless), suggests again that the problem is the bundling as mentioned in this comment. The fat JAR packager does not correctly merge entries in
META-INF/services
, meaning you are left with only a single plugin.– Harald K
We had those services issues back when we did create fat jars for a webstart. Our merging code for gradle might be helpfull 😃
There were some specifics for jai-imageio, which needs some manifest entries, and not including bouncy castle in the merging to preserve the signed security provider classes.