m47k0
October 19, 2019, 12:37pm
1
hi
looking to read exif data & found:
which led to metadata-extractor.
https://drewnoakes.com/code/exif/
Extracts Exif, IPTC, XMP, ICC and other metadata from image and video files - drewnoakes/metadata-extractor
I appear to be able to import the jar after setting it up in the Processing library, but then it fails at basic commands
// lots of metadata-extractor import statements here…
File jpegFile;
Metadata metadata;
void setup() {
size(960,640);
jpegFile = new File("test_DSC2894.jpg");
metadata = ImageMetadataReader.readMetadata(jpegFile);
}
‘Unhandled exception type ImageProcessingException’
any thoughts?
thanks
Mark
1 Like
Hmm. Example on repo homepage is to load a path, not a File object-- although both may be valid.
Search the repo for ImageProcessingException. My guess is that you need to add a try / catch around your read to catch that exception, even if you do nothing but quit().
https://processing.org/reference/try.html
m47k0
October 22, 2019, 6:32pm
3
hi
thanks for trying …
but get same error from try / catch
File jpegFile;
Metadata metadata;
void setup() {
size(960,640);
jpegFile = new File("test_DSC2894.jpg");
try {
metadata = ImageMetadataReader.readMetadata(jpegFile);
} catch (IOException e) {
e.printStackTrace();
}
}
No, don’t catch IOException. Catch ImageProcessingException. The one that the error is saying is unhandled. Handle that one. And / or check where the handing is failing, so that your wrapping location is correct.
1 Like
m47k0
October 23, 2019, 7:57pm
5
thanks for reply
I’d tried that it gives error
‘Unhandled exception type IOException’
does this shed ant further light?
Every time you get an unhandled, you add a catch (except
).
Unhandled Foo
try {
} except (Foo e) {
}
Unhandled Bar
try {
} except (Foo e) {
} except (Bar e) {
}
Unhandled Baz
try {
} except (Foo e) {
} except (Bar e) {
} except (Baz e) {
}
If an error asks you to handle an exception, handle the exception.
1 Like
m47k0
October 24, 2019, 7:34pm
7
hi
got it working
needs path + two exceptions
below is proof of concept which dumps all exif etc to console
thanks for assist
Mark
// above this all metadata-extractor import stuff
File jpegFile;
Metadata metadata;
void setup() {
size(960,640);
jpegFile = new File("Documents/Proc3/exif_test2/test_DSC2894.jpg");
try {
metadata = ImageMetadataReader.readMetadata(jpegFile);
println(metadata, "Using ImageMetadataReader");
for (Directory directory : metadata.getDirectories()) {
for (Tag tag : directory.getTags()) {
System.out.println(tag);
}
}
} catch (ImageProcessingException e) {
println(e);
} catch (IOException e) {
print(e);
}
}
1 Like