r0bot
r0bot

Reputation: 23

extract .jpg metadata / metadata-extractor / exif / java

I want to pose the date and, in particular, the time of the picture.jpg was taken. I found on the web that I can deal the issue with the (metadata-extractor) but whatever I'm trying brings no effects. Can you direct me possibly the simplest way to use this tool?

My trials were like

public class ImageMetadata{
  public static void main(String[] arg){
    Metadata metadata = null;
    try{
        FileInputStream InputStream
           = new FileInputStream(
              "X://2015//Java//renamePict//pict/IMGP0092.JPG");
        metadata = ImageMetadataReader.readMetadata(InputStream);
    } catch(Exception Ex) {ex.printStackTrace;}
    System.out.println(metadata); // I know that perhaps I should use here some toString(). It is just try to check the compilation.
  }
}

which brings me:

 Exception in thread "main" java.lang.NoClassDefFoundError: com/adobe/xmp/XMPException
 at com.drew.imaging.jpeg.JpegMetadataReader.<clinit>(JpegMetadataReader.java:53)
 at com.drew.imaging.ImageMetadataReader.readMetadata(ImageMetadataReader.java:98)
 at ImageMetadata.main(ImageMetadata.java:57)
Caused by: java.lang.ClassNotFoundException: com.adobe.xmp.XMPException
 at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
 ... 3 more

Java Result: 1 BUILD SUCCESSFUL (total time: 1 second)

Link to the

metadata-extractor

Thanks in advance!

Upvotes: 2

Views: 1863

Answers (3)

Drew Noakes
Drew Noakes

Reputation: 311127

If you reference metadata-extractor using Maven, the reference to XmpCore will be picked up automatically.

Upvotes: 0

Channa Jayamuni
Channa Jayamuni

Reputation: 1905

Add xmp-core library into your project. Please consider xmp-core version you needed. Follow these step to get xmp-core 5.1.2 version.

If you are using ant builder download following jar file and add into your project.

xmpcore-5.1.2.jar

If you are using maven, add following dependency into your pom.xml

<dependency>
    <groupId>com.adobe.xmp</groupId>
    <artifactId>xmpcore</artifactId>
    <version>5.1.2</version>
</dependency>

use this url to access maven repository of xmp-code library.

Upvotes: 2

malaguna
malaguna

Reputation: 4233

I think you are missing xmpcore dependency, if you are using maven, here you are with this artifact : http://mvnrepository.com/artifact/com.adobe.xmp/xmpcore

<dependency>
    <groupId>com.adobe.xmp</groupId>
    <artifactId>xmpcore</artifactId>
    <version>5.1.2</version>
</dependency>

Upvotes: 1

Related Questions