dragon66 / icafe

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

Failed to find a way to read JPEG XP Comments #69

Closed ivanooi closed 6 years ago

ivanooi commented 6 years ago

Hi,

I'm so sorry. I can't find a way to read the XP Comments data out.,,

Exif exif = (JpegExif)metadataMap.get(MetadataType.EXIF ); exif.getImageIFD().getFieldAsString( TiffTag.WINDOWS_XP_COMMENT )

and it return this :
[0x10,0x30,0xF3,0x97,0xA7,0x63,0x11,0x30,0x49,0x84 ...] => 【音控】葉曙欽(濟洸)在測試音響testing 123..

anyway that I can just get the real comments?

Thanks

dragon66 commented 6 years ago

@ivanooi you can try this: TiffTag.WINDOWS_XP_COMMENT.getFieldAsString(exif.getImageIFD().getField( TiffTag.WINDOWS_XP_COMMENT).getData()).

It is a bit complex as WINDOWS_XP_COMMENT is actually a byte type field not an ASCII field. Hope this will work for you.

Wen

ivanooi commented 6 years ago

Thanks! it work! ya... not easy to figure out this. Nice if this will included in wiki as well. :-D 👍

Thanks

ivanooi commented 6 years ago

hmm...sorry, this 2 a bit strange. the 2nd statement able to return the value but not the 1st one.

     lobj_value = TiffTag.COPYRIGHT.getFieldAsString(exif.getImageIFD().getField( TiffTag.COPYRIGHT).getData());
     System.out.println(lobj_value);

     System.out.println("COPYRIGHT=" + exif.getImageIFD().getFieldAsString( TiffTag.COPYRIGHT ));
dragon66 commented 6 years ago

@ivanooi to make it consistent, I have changed the IFD.getFieldAsString(Tag) method. Please pull the latest change and give it a try. From now on, the second one will work for all cases.

ivanooi commented 6 years ago

Great! Thanks! :-D