我想写XPKeywords在JPEG图像。直到现在我使用Sansaleen的Java API为JPEG图像的Exif写入标签。我能写出最喜欢的主题,评论,作者,等级标签,但我不能写的Windows XP关键词。我使用低于code:
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, comment, author, rating but I am not able to write Windows XP Keywords. I am using below code:
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.length(), metaDataToChange.getBytes("UTF-16"));
return tiffOutputField;
}
我用Google搜索这个问题,才知道,XP_Keyword接受特殊的连接在UCS2 $ C $的CD,所以我已经更新了我的code。但还是没能写出完整标签。标签是分号分隔。
I have googled this issue and came to know that XP_Keyword accept special encoded in UCS2 so I have updated my code. But still not able to write complete tags. Tags are semi-colon separated.
请让我知道如果有present对上述问题的任何决议或有任何其他Java / Android的LIB可以在JPEG文件写入标签。
Please let me know if there present any resolution for the above issue or is there any other java/android lib which can write Tags in Jpeg files.
得到它的工作:
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;
}
只要使用字节长度UTF-16,然后写。此外,确保你修剪字符不包括任何空格。 (;)另外,请用分号分隔字符串给一个尝试。作为默认的Windows采取分号隔开的关键字
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.
上一篇:是否有可能在XAML画布的儿童属性绑定?有可能、画布、绑定、属性
下一篇:修改Grafika Texture2dProgram画画中画(或纹理纹理)纹理、Grafika、Texture2dProgram