Skip to main content

Metadata, EXIF

12 replies [Last post]
mthornton
Offline
Joined: 2003-06-10

I wanted to extract some information from my collection of images some of which are in RAW form and some jpeg. They all contain EXIF info which has the information I want.

Using the jrawio plugin for the RAW files results in the data appearing in both the native format meta data and in the standard form. Sadly, with JPEG the data is hidden inside an unknown tag which I will have to decode myself, and those items with corresponding 'standard' entries do not appear in the standard metadata.
It would be nice if an EXIF format name was offered in both cases (where present) as this would give me a single place to look.

Is there any chance of the jpeg image reader being extended to copy items from the exif data into the standard metadata format where an appropriate standard entry is defined (as for example the image creation date/time)?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mthornton
Offline
Joined: 2003-06-10

Code (66 lines) http://www.thornton.dyndns.org/mark/Java/imageio/src/TestMetadataExtract...

Image (85K): http://www.thornton.dyndns.org/mark/Java/imageio/images/PB120039-a.jpg

Larger version of the image (5MB) http://www.thornton.dyndns.org/mark/Java/imageio/images/PB120039.jpg
The errors are slightly different with the larger version

When I run the code with just the path to the smaller test image as an argument I get the following output:

----------------------------------
Test images\PB120039-a.JPG
Reader 0: com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader
Check image: 0
numThumbnails: 1
Check image: 1
numThumbnails: 1
Check image: 2
numThumbnails: 1
Check image: 3
numThumbnails: 1
Check image: 4
numThumbnails: 1
Check image: 5
numThumbnails: 1
Check image: 6
numThumbnails: 1
Check image: 7
numThumbnails: 1
Check image: 8
numThumbnails: 1
Check image: 9
numThumbnails: 1
Reader 1: com.sun.imageio.plugins.jpeg.JPEGImageReader
Check image: 0
numThumbnails: 0
Check image: 1
java.lang.IndexOutOfBoundsException
at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(JPEGImageReader.java:454)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.getImageMetadata(JPEGImageReader.java:902)
at thornton.photo.test.TestMetadataExtraction.testFile(TestMetadataExtraction.java:45)
(rest of stack trace omitted)

--------------------------------

Adding the -search option before the file forces it to count the number of images and now we get the right result.

Brian Burkhalter

We ran the test on the larger image and indeed there appears to be a problem.
It might be a duplicate of this issue:

https://jai-imageio-core.dev.java.net/issues/show_bug.cgi?id=109

We'll need to investigate further.

On Sat, 1 Sep 2007, jai-imageio@javadesktop.org wrote:

> Code (66 lines) http://www.thornton.dyndns.org/mark/Java/imageio/src/TestMetadataExtract...
>
> Image (85K): http://www.thornton.dyndns.org/mark/Java/imageio/images/PB120039-a.jpg
>
> Larger version of the image (5MB) http://www.thornton.dyndns.org/mark/Java/imageio/images/PB120039.jpg
> The errors are slightly different with the larger version
>
> When I run the code with just the path to the smaller test image as an argument I get the following output:
>
> ----------------------------------
> Test images\PB120039-a.JPG
> Reader 0: com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader
> Check image: 0
> numThumbnails: 1
> Check image: 1
> numThumbnails: 1
> Check image: 2
> numThumbnails: 1
> Check image: 3
> numThumbnails: 1
> Check image: 4
> numThumbnails: 1
> Check image: 5
> numThumbnails: 1
> Check image: 6
> numThumbnails: 1
> Check image: 7
> numThumbnails: 1
> Check image: 8
> numThumbnails: 1
> Check image: 9
> numThumbnails: 1
> Reader 1: com.sun.imageio.plugins.jpeg.JPEGImageReader
> Check image: 0
> numThumbnails: 0
> Check image: 1
> java.lang.IndexOutOfBoundsException
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(JPEGImageReader.java:454)
> at com.sun.imageio.plugins.jpeg.JPEGImageReader.getImageMetadata(JPEGImageReader.java:902)
> at thornton.photo.test.TestMetadataExtraction.testFile(TestMetadataExtraction.java:45)
> (rest of stack trace omitted)
>
> --------------------------------
>
> Adding the -search option before the file forces it to count the number of images and now we get the right result.
> [Message sent by forum member 'mthornton' (mthornton)]
>
> http://forums.java.net/jive/thread.jspa?messageID=233553
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

mthornton
Offline
Joined: 2003-06-10

I will do some more testing and see if I can post an example (but not tonight, it is about time to throw the cats out ...)

The Java SE reader doesn't have the problem (but then it also ignores the EXIF sections).

Brian Burkhalter

On Fri, 31 Aug 2007, jai-imageio@javadesktop.org wrote:

> I will do some more testing and see if I can post an example (but not tonight, it is about time to throw the cats out ...)

As in herding ... or as in felines?

> The Java SE reader doesn't have the problem (but then it also ignores the EXIF sections).

You should still be able to grab the APP1 EXIF marker segment from the
metadata.

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Brian Burkhalter

Have you read these sections of the javadoc?:

http://download.java.net/media/jai-imageio/javadoc/1.1/overview-summary....
http://download.java.net/media/jai-imageio/javadoc/1.1/com/sun/media/ima...

Brian

On Fri, 31 Aug 2007, jai-imageio@javadesktop.org wrote:

> I wanted to extract some information from my collection of images some of which are in RAW form and some jpeg. They all contain EXIF info which has the information I want.
>
> Using the jrawio plugin for the RAW files results in the data appearing in both the native format meta data and in the standard form. Sadly, with JPEG the data is hidden inside an unknown tag which I will have to decode myself, and those items with corresponding 'standard' entries do not appear in the standard metadata.
> It would be nice if an EXIF format name was offered in both cases (where present) as this would give me a single place to look.
>
> Is there any chance of the jpeg image reader being extended to copy items from the exif data into the standard metadata format where an appropriate standard entry is defined (as for example the image creation date/time)?
> [Message sent by forum member 'mthornton' (mthornton)]
>
> http://forums.java.net/jive/thread.jspa?messageID=233479
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

mthornton
Offline
Joined: 2003-06-10

"The JPEG reader supports TIFF native image metadata as an extra metadata format. If the JPEG stream contains an EXIF APP1 marker segment, the primary IFD contained therein will be available from the metadata tree extracted using the TIFF extra metadata format name."

Not however the first JPEG reader you get with JDK6 u1. Which version has this enhancement?

Brian Burkhalter

The one in JAI Image I/O Tools which is the product associated with this
mailing list (the Java SE Image I/O stuff is
java-imageio-interest@java.sun.com).

Binaries are available via the container project
https://jai-imageio.dev.java.net and source code via its subproject
https://jai-imageio-core.dev.java.net.

On Fri, 31 Aug 2007, jai-imageio@javadesktop.org wrote:

> "The JPEG reader supports TIFF native image metadata as an extra metadata format. If the JPEG stream contains an EXIF APP1 marker segment, the primary IFD contained therein will be available from the metadata tree extracted using the TIFF extra metadata format name."
>
> Not however the first JPEG reader you get with JDK6 u1. Which version has this enhancement?
> [Message sent by forum member 'mthornton' (mthornton)]
>
> http://forums.java.net/jive/thread.jspa?messageID=233488
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

mthornton
Offline
Joined: 2003-06-10

> The one in JAI Image I/O Tools which is the product
> associated with this
> mailing list (the Java SE Image I/O stuff is
> java-imageio-interest@java.sun.com).
>

Thanks. It hadn't occured to me that the two had different discussion groups. (I'm using the web forum reached via java.net forums).

Brian Burkhalter

On Fri, 31 Aug 2007, jai-imageio@javadesktop.org wrote:

>> The one in JAI Image I/O Tools which is the product
>> associated with this
>> mailing list (the Java SE Image I/O stuff is
>> java-imageio-interest@java.sun.com).
>>
>
> Thanks. It hadn't occured to me that the two had different discussion groups. (I'm using the web forum reached via java.net forums).

It isn't really obvious.

Note that the reading methodology using the "unknown" node should work for
either JPEG reader. It's the TIFF reader that simplifies things.

Brian

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

mthornton
Offline
Joined: 2003-06-10

I have now tried version 1.1 ... and get
java.lang.OutOfMemoryError: Java heap space

I try to retrieve the metadata for each image in a file in turn, expecting an exception when it looks for an image which doesn't exist. This is to avoid an upfront count of the images in those file formats where that is expensive. The heap runs out of space when reporting the metadata retrieved for the first image which isn't really there! I.e. the expected (IndexOutOfBounds or similar) exception doesn't happen. If I instead ask for the number of thumbnails at this point, the imageReader goes into an infinite loop.

The image reader is com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader

Brian Burkhalter

Do you suppose you could post a test?

On Fri, 31 Aug 2007, jai-imageio@javadesktop.org wrote:

> I have now tried version 1.1 ... and get
> java.lang.OutOfMemoryError: Java heap space
>
> I try to retrieve the metadata for each image in a file in turn, expecting an exception when it looks for an image which doesn't exist. This is to avoid an upfront count of the images in those file formats where that is expensive. The heap runs out of space when reporting the metadata retrieved for the first image which isn't really there! I.e. the expected (IndexOutOfBounds or similar) exception doesn't happen. If I instead ask for the number of thumbnails at this point, the imageReader goes into an infinite loop.
>
> The image reader is com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReader
> [Message sent by forum member 'mthornton' (mthornton)]
>
> http://forums.java.net/jive/thread.jspa?messageID=233520
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail: interest-help@jai-imageio.dev.java.net
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

bpb
Offline
Joined: 2004-06-23

One more thing is you might want to see whether the same problem obtains if you use the Java SE JPEG reader which will be the second one in the iteration.

> Do you suppose you could post a test?
>
> On Fri, 31 Aug 2007, jai-imageio@javadesktop.org
> wrote:
>
> > I have now tried version 1.1 ... and get
> > java.lang.OutOfMemoryError: Java heap space
> >
> > I try to retrieve the metadata for each image in a
> file in turn, expecting an exception when it looks
> for an image which doesn't exist. This is to avoid an
> upfront count of the images in those file formats
> where that is expensive. The heap runs out of space
> when reporting the metadata retrieved for the first
> image which isn't really there! I.e. the expected
> (IndexOutOfBounds or similar) exception doesn't
> happen. If I instead ask for the number of thumbnails
> at this point, the imageReader goes into an infinite
> loop.
> >
> > The image reader is
> com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageRe
> ader
> > [Message sent by forum member 'mthornton'
> (mthornton)]
> >
> >
> http://forums.java.net/jive/thread.jspa?messageID=2335
> 20
> >
> >
> ------------------------------------------------------
> ---------------
> > To unsubscribe, e-mail:
> interest-unsubscribe@jai-imageio.dev.java.net
> > For additional commands, e-mail:
> interest-help@jai-imageio.dev.java.net
> >
> >
>
> ----------------
> Brian Burkhalter
> Java Media, Imaging, and Graphics
> Sun Microsystems, Inc.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
> This email message is for the sole use of the
> intended recipient(s)
> and may contain confidential and privileged
> information. Any
> unauthorized review, use, disclosure or distribution
> is prohibited.
> If you are not the intended recipient, please contact
> the sender by
> reply email and destroy all copies of the original
> message.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~
>
> ------------------------------------------------------
> ---------------
> To unsubscribe, e-mail:
> interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail:
> interest-help@jai-imageio.dev.java.net