Red*_*fox 16 tags android exif gps-time
我试图通过android将"GPSTimeStamp"设置为jpg的exif标签.这篇文档非常缺乏:
http://developer.android.com/reference/android/media/ExifInterface.html#TAG_GPS_TIMESTAMP
Type是String.常数值:"GPSTimeStamp".但确切的格式是什么?
在这里查看:
http:
//www.sno.phy.queensu.ca/~phil/exiftool/TagNames/GPS.html GPSTimeStamp:rational64u [3](写入时,如果存在,日期将被删除,时间将调整为UTC如果它包括时区)
所以我需要一个长值的3单元阵列?我不确定,该放什么.我已经获得了"此修复的UTC时间,自1970年1月1日起以毫秒为单位." 通过location.gettime().
http://developer.android.com/reference/android/location/Location.html#getTime%28%29
如果我将长值作为字符串写入时间戳并通过Linux上的"exif"检查exif标签,我得到错误"分母预期".所有使用hh:mm:ss或其他格式的实验都失败了.在这里有点迷失.
GPSTimeStamp采样时间属性的正确格式14:22:32是
"14/1,22/1,32/1"
Run Code Online (Sandbox Code Playgroud)
您可以使用以下代码:
Location location = ...; // TODO - Set location properly.
long locationTome = location.getTime();
ExifInterface imageExif = new ExifInterface("absolute_path_to_image");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(locationTome);
int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY);
int minutes = calendar.get(Calendar.MINUTE);
int seconds = calendar.get(Calendar.SECOND);
String exifGPSTimestamp = hourOfDay + "/1," + minutes + "/1," + seconds + "/1";
imageExif.setAttribute("GPSTimeStamp", exifGPSTimestamp);
imageExif.saveAttributes();
Run Code Online (Sandbox Code Playgroud)
它具有与GPSLatitude和GPSLongitude属性类似的格式。这种格式的有用解释也可以在这里找到:http://www.ridgesolutions.ie/index.php/2015/03/05/geotag-exif-gps-latitude-field-format/
| 归档时间: |
|
| 查看次数: |
3054 次 |
| 最近记录: |