dragon66 / icafe

Java library for reading, writing, converting and manipulating images and metadata
Eclipse Public License 1.0
203 stars 58 forks source link

Failed to read XMP data #68

Closed ivanooi closed 6 years ago

ivanooi commented 6 years ago

Hi ,

I got an example image which contained XMP data but iCafe failed to read it. Or i miss some things ?

Anyway i can send you the sample code and image ?

Thanks

dragon66 commented 6 years ago

@ivanooi Please send the image and code to me. I would like to do a test.

ivanooi commented 6 years ago

Hi ,

Sample code and image sent to your email yuwen_66@yahoo.com

Thanks again Ivan

dragon66 commented 6 years ago

@ivanooi I tested with your image and code and I can see that icafe read XMP information perfectly. What made you think icafe failed to read XMP?

ivanooi commented 6 years ago

Oh! That Great! Is it some things wrong with code ?

ivanooi commented 6 years ago
     fin = new FileInputStream("test.JPG");//20171209_214631

     Map<MetadataType, Metadata> metadataMap = Metadata.readMetadata( fin );

     int i = 0;
     for(Map.Entry<MetadataType, Metadata> entry : metadataMap.entrySet()) {
        System.out.println( i + "=" + entry.getKey());
        entry.getValue().showMetadata();
        i++;
     }

     XMP xmp = (XMP)metadataMap.get(MetadataType.XMP);
     XMP jpegXmp = null;

     if( xmp != null ){

        Document xmpDoc = xmp.getMergedDocument();

        System.out.println("xmp");
        System.out.println(xmp.getXmpDocument().getTextContent());
        System.out.println();
        System.out.println();
        System.out.println("xmpDoc");
        System.out.println(xmpDoc.getDocumentURI());

        jpegXmp = new JpegXMP(XMLUtils.serializeToByteArray(xmpDoc));

// Metadata.insertXMP(fin, fout, jpegXmp);
}

ivanooi commented 6 years ago

Hi.

Is it I need the latest source? If I used the pre-compiled jar files. This is the result I get :

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 0=EXIF 1=XMP 2=IMAGE xmp null

xmpDoc null

dragon66 commented 6 years ago

@ivanooi You need to include a few libraries including the logging library which is SLF4J along with icafe.jar to make it work properly.

The null output from your comment is not a big deal as that happens to DOM document model. Although it shows null, there is actually nothing wrong. The final result will be fine.

I tested with your code, it is working fine. I am not sure why you commented out the last line which actually does the insertion of XMP to the target image and I also didn't see the "fout" defined.

ivanooi commented 6 years ago

Hi ,

Thanks for your help. You are right! I managed to grab the XML using the XMLUtils . I commentted that out as just wanted to test only. I will post the few statements here.

Yape ! Thanks alot ! It work as advertise 😂 I'm switching from Apache library to iCafe now