Skip to main content

Read EXIF Metadata from TIFF image using JAI

5 replies [Last post]
sanjayagrawal007
Offline
Joined: 2009-01-27
Points: 0

Hi,

I need help to read EXIF metadata from TIFF Image using JAI. If I open the TIFF image in ACDSee 6.0 I can see the metadata information.

I want to retrieve 'Image Description' from EXIF metadata using JAI.

Please help.
Thanks
san

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sanjayagrawal007
Offline
Joined: 2009-01-27
Points: 0

Thanks for helping me.

marcojacob
Offline
Joined: 2006-07-10
Points: 0

You should have a look at the ImageIO API javax.imageio of your JDK.
ImageIO can provide the IIOMetadata. JAI ImageIO provides you with
the codec for TIFF.

Example to read metadata:
http://johnbokma.com/java/obtaining-image-metadata.html

This is the ImageIO standard metadata format:
http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/metadata/doc-files...

And this is the TIFF native metadata format:
http://download.java.net/media/jai-imageio/javadoc/1.2-latest/com/sun/me...

Message was edited by: marcojacob

sanjayagrawal007
Offline
Joined: 2009-01-27
Points: 0

Hi MarcoJacob,

Your information was very helpful, thank a lot.

Still I didn't get the solution.

I want to read value /Text/TextEntry element from metadata information.

Please help me if you can.

marcojacob
Offline
Joined: 2006-07-10
Points: 0

At first you need to search the two metadata formats.
If the plugin neutral format "javax_imageio_1.0" lasts for your needs
you should use it. Otherwise you would have to code for each format.

IIOMetadata meta = ...;

// the two root node names of the metadata tree
// and javax_imageio_1.0 or native com_sun_media_imageio_plugins_tiff_image_1.0
String[] formats = meta.getMetadataFormatNames();
// Example getting neutral xml tree
Document xmlDoc = (Document)meta.getAsTree("javax_imageio_1.0");
NodeList nodes = xmlDoc.getElementsByTagName("Text/TextEntry");
for (int i=0; i< nodes.getLength(); i++) {
String txt = nodes.item(i);
System.out.println(txt);
}

I modified the example to fit your needs.
This is from scratch so maybe some code doesn't
compile at once.

Message was edited by: marcojacob

sanjayagrawal007
Offline
Joined: 2009-01-27
Points: 0

I am just providing more information.

I can read image parameters by using this code.

File imageFile = new File("C:\\abc.TIF");

FileSeekableStream decoderStream = new FileSeekableStream(imageFile);

ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", decoderStream,
new TIFFDecodeParam());

int numberOfPages = decoder.getNumPages();

System.out.println(numberOfPages);