Tried to improve GPSTimeStamp conversions, extended tests.
This commit is contained in:
parent
21c20e5ae0
commit
c463cdd283
@ -546,7 +546,14 @@ namespace Exiv2 {
|
||||
else { // "Exif.GPSInfo.GPSTimeStamp"
|
||||
double dhour = pos->value().toFloat(0);
|
||||
double dmin = pos->value().toFloat(1);
|
||||
double dsec = pos->value().toFloat(2);
|
||||
// Hack: Need Value::toDouble
|
||||
URational r = pos->value().toRational(2);
|
||||
if (r.second == 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
||||
#endif
|
||||
}
|
||||
double dsec = static_cast<double>(r.first)/r.second;
|
||||
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
@ -812,11 +819,22 @@ namespace Exiv2 {
|
||||
}
|
||||
}
|
||||
else { // "Exif.GPSInfo.GPSTimeStamp"
|
||||
Rational rhour(datetime.hour, 1);
|
||||
Rational rmin(datetime.minute, 1);
|
||||
Rational rsec = floatToRationalCast(
|
||||
static_cast<float>(datetime.second + datetime.nanoSecond / 1000000000.0)
|
||||
);
|
||||
|
||||
// Ignore the time zone, assuming the time is in UTC as it should be
|
||||
|
||||
URational rhour(datetime.hour, 1);
|
||||
URational rmin(datetime.minute, 1);
|
||||
URational rsec(datetime.second, 1);
|
||||
if (datetime.nanoSecond != 0) {
|
||||
if (datetime.second != 0) {
|
||||
// Add the seconds to rmin so that the ns fit into rsec
|
||||
rmin.second = 60;
|
||||
rmin.first *= 60;
|
||||
rmin.first += datetime.second;
|
||||
}
|
||||
rsec.second = 1000000000;
|
||||
rsec.first = datetime.nanoSecond;
|
||||
}
|
||||
|
||||
std::ostringstream array;
|
||||
array << rhour << " " << rmin << " " << rsec;
|
||||
|
||||
@ -183,12 +183,14 @@ echo Testcase 14
|
||||
echo ===========
|
||||
\cp $IMG u.jpg
|
||||
$exiv2 -M'set Exif.Photo.DateTimeOriginal 2003:12:14 12:01:44' u.jpg
|
||||
$exiv2 -M'set Exif.Photo.SubSecTimeOriginal 999999999' u.jpg
|
||||
$exiv2 -M'set Exif.Photo.ExifVersion 48 50 50 49' u.jpg
|
||||
$exiv2 -M'set Exif.Photo.ComponentsConfiguration 1 2 3 0' u.jpg
|
||||
$exiv2 -M'set Exif.Photo.Flash 73' u.jpg
|
||||
$exiv2 -M'set Exif.GPSInfo.GPSLatitude 3/1 8/1 29734512/1000000' u.jpg
|
||||
$exiv2 -M'set Exif.GPSInfo.GPSLatitudeRef N' u.jpg
|
||||
$exiv2 -M'set Exif.GPSInfo.GPSVersionID 2 2 0 1' u.jpg
|
||||
$exiv2 -M'set Exif.GPSInfo.GPSTimeStamp 1/1 2/1 999999999/1000000000' u.jpg
|
||||
$exiv2 -M'set Iptc.Application2.DateCreated 2007-05-09' u.jpg
|
||||
|
||||
$exiv2 -Pkycv u.jpg
|
||||
@ -205,6 +207,7 @@ echo Testcase 15
|
||||
echo ===========
|
||||
\cp $IMG v.jpg
|
||||
\cp u.xmp v.xmp
|
||||
$exiv2 -M'set Xmp.tiff.DateTime 2003-12-14T12:01:44Z' v.xmp
|
||||
$exiv2 -iX v.jpg
|
||||
$exiv2 -px v.jpg
|
||||
$exiv2 -Pkycv v.jpg
|
||||
|
||||
@ -92,3 +92,73 @@ Testcase 13
|
||||
Xmp.iptc.Location XmpText 12 Kuala Lumpur
|
||||
t.jpg: No Exif data found in the file
|
||||
Iptc.Application2.LocationName String 12 Kuala Lumpur
|
||||
|
||||
Testcase 14
|
||||
===========
|
||||
Exif.Image.ExifTag Long 1 38
|
||||
Exif.Image.GPSTag Long 1 134
|
||||
Exif.Photo.ExifVersion Undefined 4 48 50 50 49
|
||||
Exif.Photo.DateTimeOriginal Ascii 20 2003:12:14 12:01:44
|
||||
Exif.Photo.ComponentsConfiguration Undefined 4 1 2 3 0
|
||||
Exif.Photo.Flash Short 1 73
|
||||
Exif.Photo.SubSecTimeOriginal Ascii 10 999999999
|
||||
Exif.GPSInfo.GPSVersionID Byte 4 2 2 0 1
|
||||
Exif.GPSInfo.GPSLatitudeRef Ascii 2 N
|
||||
Exif.GPSInfo.GPSLatitude Rational 3 3/1 8/1 29734512/1000000
|
||||
Exif.GPSInfo.GPSTimeStamp Rational 3 1/1 2/1 999999999/1000000000
|
||||
Iptc.Application2.DateCreated Date 8 2007-05-09
|
||||
Xmp.exif.ExifVersion XmpText 4 2.21
|
||||
Xmp.exif.DateTimeOriginal XmpText 29 2003-12-14T12:01:44.999999999
|
||||
Xmp.exif.GPSVersionID XmpText 7 2.2.0.1
|
||||
Xmp.exif.GPSLatitude XmpText 12 3,8.4955752N
|
||||
Xmp.exif.GPSTimeStamp XmpText 29 2003-12-14T01:02:00.999999999
|
||||
Xmp.exif.ComponentsConfiguration XmpSeq 4 YCbCr
|
||||
Xmp.exif.Flash XmpText 0 type="Struct"
|
||||
Xmp.exif.Flash/exif:Fired XmpText 4 True
|
||||
Xmp.exif.Flash/exif:Return XmpText 1 0
|
||||
Xmp.exif.Flash/exif:Mode XmpText 1 1
|
||||
Xmp.exif.Flash/exif:Function XmpText 5 False
|
||||
Xmp.exif.Flash/exif:RedEyeMode XmpText 4 True
|
||||
Xmp.photoshop.DateCreated XmpText 10 2007-05-09
|
||||
Exif.Photo.ExifVersion Undefined 4 48 50 50 49
|
||||
Exif.Photo.ComponentsConfiguration Undefined 4 1 2 3 0
|
||||
Exif.Photo.DateTimeOriginal Ascii 20 2003:12:14 12:01:44
|
||||
Exif.Photo.SubSecTimeOriginal Ascii 10 999999999
|
||||
Exif.Photo.Flash Short 1 73
|
||||
Exif.GPSInfo.GPSVersionID Byte 4 2 2 0 1
|
||||
Exif.GPSInfo.GPSLatitude Rational 3 3/1 8/1 1858407/62500
|
||||
Exif.GPSInfo.GPSLatitudeRef Ascii 2 N
|
||||
Exif.GPSInfo.GPSTimeStamp Rational 3 1/1 2/1 999999999/1000000000
|
||||
Exif.GPSInfo.GPSDateStamp Ascii 11 2003:12:14
|
||||
Iptc.Application2.DateCreated Date 8 2007-05-09
|
||||
|
||||
Testcase 15
|
||||
===========
|
||||
Xmp.exif.ExifVersion XmpText 4 2.21
|
||||
Xmp.exif.DateTimeOriginal XmpText 29 2003-12-14T12:01:44.999999999
|
||||
Xmp.exif.GPSVersionID XmpText 7 2.2.0.1
|
||||
Xmp.exif.GPSLatitude XmpText 12 3,8.4955752N
|
||||
Xmp.exif.GPSTimeStamp XmpText 29 2003-12-14T01:02:00.999999999
|
||||
Xmp.exif.Flash XmpText 0 type="Struct"
|
||||
Xmp.exif.Flash/exif:Fired XmpText 4 True
|
||||
Xmp.exif.Flash/exif:Return XmpText 1 0
|
||||
Xmp.exif.Flash/exif:Mode XmpText 1 1
|
||||
Xmp.exif.Flash/exif:Function XmpText 5 False
|
||||
Xmp.exif.Flash/exif:RedEyeMode XmpText 4 True
|
||||
Xmp.exif.ComponentsConfiguration XmpSeq 4 YCbCr
|
||||
Xmp.tiff.DateTime XmpText 20 2003-12-14T12:01:44Z
|
||||
Xmp.photoshop.DateCreated XmpText 10 2007-05-09
|
||||
Exif.Image.DateTime Ascii 20 2003:12:14 20:01:44
|
||||
Exif.Image.ExifTag Long 1 70
|
||||
Exif.Image.GPSTag Long 1 166
|
||||
Exif.Photo.ExifVersion Undefined 4 48 50 50 49
|
||||
Exif.Photo.DateTimeOriginal Ascii 20 2003:12:14 12:01:44
|
||||
Exif.Photo.ComponentsConfiguration Undefined 4 1 2 3 0
|
||||
Exif.Photo.Flash Short 1 73
|
||||
Exif.Photo.SubSecTimeOriginal Ascii 10 999999999
|
||||
Exif.GPSInfo.GPSVersionID Byte 4 2 2 0 1
|
||||
Exif.GPSInfo.GPSLatitudeRef Ascii 2 N
|
||||
Exif.GPSInfo.GPSLatitude Rational 3 3/1 8/1 1858407/62500
|
||||
Exif.GPSInfo.GPSTimeStamp Rational 3 1/1 2/1 999999999/1000000000
|
||||
Exif.GPSInfo.GPSDateStamp Ascii 11 2003:12:14
|
||||
Iptc.Application2.DateCreated Date 8 2007-05-09
|
||||
|
||||
Loading…
Reference in New Issue
Block a user