使用ExifInterface设置Datetime发生的问题

最近在弄一个Android小程序,需要把图像的生成时间设置到Exif的Datetime,用ExifInterface.setAttribute(ExifInterface.TAG_DATETIME,"2014/12/12 12:12:12")这种设置方式没有用,程序执行没有任何错误,也没有任何作用,设置不成功,到AndroidAPI的官网查也没有任何说明。

只能求助于Google老师(幸亏在海外,还能查),最终找到了这篇文章。http://www.media.mit.edu/pia/Research/deepview/exif.html,关于Exif的格式有明确的记载,其中关于Datetime有如下说明,

0x0132 DateTime  ascii string 20  Date/Time of image was last modified. Data format is "YYYY:MM:DD HH:MM:SS"+0x00, total 20bytes. In usual, it has the same value of DateTimeOriginal(0x9003)

也就是说,DateTime必须设置成“YYYY:MM:DD HH:MM:SS”的样式。

这样刚才执行没有任何作用的程序修改成:ExifInterface.setAttribute(ExifInterface.TAG_DATETIME,"2014:12:12 12:12:12")就可以把时间信息存入图像的Exif信息了。

关于Exif信息的由来,可以参照如下文章:

http://zh.wikipedia.org/wiki/EXIF

posted @ 2014-12-20 20:07  West Continent  阅读(1277)  评论(0编辑  收藏  举报