Writing XPKeywords in Exif

后端 未结 1 489
醉话见心
醉话见心 2021-01-07 13:07

I want to write XPKeywords in a Jpeg Image. Till now I am using Sansaleen java api for writing Exif tags in Jpeg images. I am able to write most of the tags like subject, co

相关标签:
1条回答
  • 2021-01-07 13:51

    Got it working:

    public static TiffOutputField getTiffOutputFieldKeyword(
        TiffOutputSet outputSet, String metaDataToChange) {
    TiffOutputField imageHistoryPre = outputSet
            .findField(TiffConstants.EXIF_TAG_XPKEYWORDS);
    if (imageHistoryPre != null) {
        outputSet.removeField(TiffConstants.EXIF_TAG_XPKEYWORDS);
    }
    
    TiffOutputField tiffOutputField = new TiffOutputField(
            TiffConstants.EXIF_TAG_XPKEYWORDS,
            TiffFieldTypeConstants.FIELD_TYPE_BYTE,
            metaDataToChange.getBytes("UTF-16").length, metaDataToChange.getBytes("UTF-16"));
    
    return tiffOutputField;
    }
    

    Just use length of Bytes in "UTF-16" and then write. Also, Make sure you trim the characters to not include any spaces. Also, please give a try by separating string with Semicolon(;) as By default Windows take semicolon separated keywords.

    0 讨论(0)
提交回复
热议问题