18

Android経由でjpgのexifタグに「GPSTimeStamp」を設定しようとしています。これに関するドキュメントはかなり不足しています:
http://developer.android.com/reference/android/media/ExifInterface.html#TAG_GPS_TIMESTAMP タイプは文字列です。定数値: "GPSTimeStamp"。しかし、正確な形式は何ですか?

ここを見る: https://ExifTool.org/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 またはその他の形式を使用した実験はすべて失敗しました。ここで少し迷っています。

4

1 に答える 1

2

GPSTimeStampサンプル時間の属性の適切な形式は次のとおり14:22:32です。

"14/1,22/1,32/1"

次のコードを使用できます。

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();

GPSLatitudeおよびGPSLongitude属性と同様の形式です。このような形式の有用な説明は、http: //www.ridgesolutions.ie/index.php/2015/03/05/geotag-exif-gps-latitude-field-format/にもあります。

于 2015-03-19T13:20:45.087 に答える