On Thu, Mar 8, 2012 at 7:02 PM, Kasper Føns <kfo...@gmail.com> wrote:
>
>> Windows Explorer also likes the "XP" values (eg. EXIF_TAG_XPCOMMENT,
>> EXIF_TAG_XPAUTHOR), maybe try writing those as well?
>
> Hmm. You seem to be right that explorer likes the XP values. However, I
> can't figure out how to write to them. I can see that they are BYTE values,
> but how to convert a string into the wanted bytes?
>
> This is the result I get:
> ---- IFD0 ----
> XP Comment                      : 態灳牥潃浭湥t
> XP Author                       : 態灳牥畁桴牯
>
> With this code:
> byte[] bytesComment =
> ExifTagConstants.EXIF_TAG_XPCOMMENT.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII,
> "KasperComment", set.byteOrder);
> byte[] bytesAuthor =
> ExifTagConstants.EXIF_TAG_XPAUTHOR.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII,
> "KasperAuthor", set.byteOrder);
> TiffOutputField commentField = new
> TiffOutputField(ExifTagConstants.EXIF_TAG_XPCOMMENT,
> ExifTagConstants.EXIF_TAG_XPCOMMENT.dataTypes[0], bytesComment.length,
> bytesComment);
> TiffOutputField authorField = new
> TiffOutputField(ExifTagConstants.EXIF_TAG_XPAUTHOR,
> ExifTagConstants.EXIF_TAG_XPAUTHOR.dataTypes[0], bytesAuthor.length,
> bytesAuthor);
> set.getOrCreateRootDirectory().add(commentField);
> set.getOrCreateRootDirectory().add(authorField);
>
>
> /Kasper

There's no easy way in Sanselan 0.97: the XP fields use little-endian
UTF-16 (no matter what the byte ordering of the file is, thanks
Microsoft you useless @*#%!) so try this:

byte[] rawBytes = "KasperAuthor".getBytes("UTF-16LE");
byte[] nullTerminatedBytes = new byte[rawBytes.length + 2];
TiffOutputField authorField = new
  TiffOutputField(ExifTagConstants.EXIF_TAG_XPAUTHOR,
  ExifTagConstants.EXIF_TAG_XPAUTHOR.dataTypes[0], nullTerminatedBytes.length,
  nullTerminatedBytes);

Damjan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to