本文整理汇总了C++中exiv2::image::AutoPtr::exifData方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr::exifData方法的具体用法?C++ AutoPtr::exifData怎么用?C++ AutoPtr::exifData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exiv2::image::AutoPtr
的用法示例。
在下文中一共展示了AutoPtr::exifData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyExif
void ExifTools::copyExif(const QString &sourceStr, const QString &destStr)
{
Exiv2::Image::AutoPtr sourceImageData =
Exiv2::ImageFactory::open(QFile::encodeName(sourceStr).data());
sourceImageData->readMetadata();
Exiv2::ExifData exifData = sourceImageData->exifData();
Exiv2::IptcData iptcData = sourceImageData->iptcData();
Exiv2::ExifThumb exifThumb(exifData);
exifThumb.erase();
Exiv2::Image::AutoPtr destImageData =
Exiv2::ImageFactory::open(QFile::encodeName(destStr).data());
destImageData->setExifData(exifData);
destImageData->setIptcData(iptcData);
destImageData->writeMetadata();
}
示例2: catch
static gfloat
expcombine_get_file_ev (const gchar *path)
{
/* Open the file and read in the metadata */
Exiv2::Image::AutoPtr image;
try
{
image = Exiv2::ImageFactory::open (path);
image->readMetadata ();
}
catch (Exiv2::Error ex)
{
g_print ("Error: unable to read metadata from path: '%s'\n", path);
exit (EXIT_FAILURE);
}
Exiv2::ExifData &exifData = image->exifData ();
if (exifData.empty ())
return NAN;
/* Calculate the APEX brightness / EV */
gfloat time, aperture, gain = 1.0f;
time = exifData["Exif.Photo.ExposureTime"].value().toFloat();
aperture = exifData["Exif.Photo.FNumber" ].value().toFloat();
/* iso */
try
{
gain = exifData["Exif.Photo.ISOSpeedRatings"].value().toLong() / 100.0f;
}
catch (Exiv2::Error ex)
{
// Assume ISO is set at 100. It's reasonably likely that the ISO is the
// same across all images anyway, and for our purposes the relative
// values can be sufficient.
gain = 1.0f;
}
return log2f (aperture * aperture) + log2f (1 / time) + log2f (gain);
}
示例3: getExifData
// tries to find a specified exif tag in a specified file
QString ExifScout::getExifData(QString fname, QString etag){
std::string filename = fname.toAscii().data();
std::string exiftag = etag.toAscii().data();
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filename);
assert(image.get() != 0);
image->readMetadata();
Exiv2::ExifData exifData = image->exifData();
if (!exifData.empty()) {
Exiv2::ExifData::const_iterator end = exifData.end();
QString output;
for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
if(i->tagName()==exiftag){
std::ostringstream oss;
oss << i->value();
return (QString)oss.str().c_str();
}
}
}
return NULL;
}
示例4: fi
bool Exiv2ReadingWorker::readMetadata(Models::ArtworkMetadata *artwork, ImportDataResult &importResult) {
const QString &filepath = artwork->getFilepath();
#if defined(Q_OS_WIN)
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filepath.toStdWString());
#else
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filepath.toStdString());
#endif
Q_ASSERT(image.get() != NULL);
image->readMetadata();
Exiv2::XmpData &xmpData = image->xmpData();
Exiv2::ExifData &exifData = image->exifData();
Exiv2::IptcData &iptcData = image->iptcData();
QString iptcEncoding = getIptcCharset(iptcData).toUpper();
bool isIptcUtf8 = (iptcEncoding == QLatin1String("UTF-8")) || (iptcEncoding == QLatin1String("UTF8"));
importResult.FilePath = filepath;
importResult.Description = retrieveDescription(xmpData, exifData, iptcData, isIptcUtf8);
importResult.Title = retrieveTitle(xmpData, exifData, iptcData, isIptcUtf8);
importResult.Keywords = retrieveKeywords(xmpData, exifData, iptcData, isIptcUtf8);
importResult.DateTimeOriginal = retrieveDateTime(xmpData, exifData, iptcData, isIptcUtf8);
MetadataSavingCopy copy;
if (copy.readFromFile(filepath)) {
importResult.BackupDict = copy.getInfo();
}
QFileInfo fi(filepath);
importResult.FileSize = fi.size();
Models::ImageArtwork *imageArtwork = dynamic_cast<Models::ImageArtwork*>(artwork);
if (imageArtwork != NULL) {
QImageReader reader(filepath);
importResult.ImageSize = reader.size();
}
return true;
}
示例5: readexiv
void ImageResolution::readexiv(char const *fn) {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fn);
if (!image.get())
return;
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
if (exifData.empty())
return;
Exiv2::ExifData::const_iterator end = exifData.end();
bool havex = false;
bool havey = false;
bool haveunit = false;
int unit;
for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
if (ok_)
break;
if (i->tag()==0x011a) {
// X Resolution
x_ = i->toFloat();
havex = true;
} else if (i->tag()==0x011b) {
// Y Resolution
y_ = i->toFloat();
havey = true;
} else if (i->tag()==0x0128) {
unit = i->toLong();
}
ok_ = havex && havey && haveunit;
}
if (haveunit) {
if (unit==3) {
x_ *= 2.54;
y_ *= 2.54;
}
}
ok_ = havex && havey;
}
示例6: getExifFromPath
Exiv2::ExifData getExifFromPath(char* filename) {
qDebug() << "Trying to read EXIF for" << filename;
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filename);
assert(image.get() != 0);
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
if (exifData.empty()) {
std::string error(filename);
error += ": No Exif data found in the file";
}
return exifData;
} catch (Exiv2::Error& e) {
Exiv2::ExifData exifData;
qCritical() << "Caught Exiv2 exception '" << e.what();
//TODO Translate
return exifData;
}
}
示例7: main
int main(int argc, char ** argv) {
logging::core::get()->set_filter
(
logging::trivial::severity >= logging::trivial::info
);
if(argc <= 4) {
BOOST_LOG_TRIVIAL(info) << "Invalid arguments for test";
return 2;
}
string description = argv[1];
Mat input = imread(argv[2], cv::IMREAD_COLOR);
BOOST_LOG_TRIVIAL(info) << "Reading " << argv[2] << " of size " << input.rows << "x" << input.cols;
vector<Point> * contour = new vector<Point>();
for(int i = 3; i + 1 < argc; i++){
stringstream ss;
int x, y;
ss << argv[i] << " " << argv[i+1];
ss >> x >> y;
contour->push_back(Point(x,y));
}
/************************************************ERIC's SHIT*/
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[2]);
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
exifData["Exif.Photo.UserComment"] = "50,-90,90,180,1:23:45";
image->writeMetadata();
std::cout << "wrote it";
/****************************************************/
BOOST_LOG_TRIVIAL(info) << "Read Contour: " << contour; // TODO: figure out why defining operator<< doesn't affect boost logs
Frame f(&input, "blah", Metadata());
TargetTest test("Target Identification using KMeans + Canny");
double result = test.do_test(f, description, contour, 10);
return !(result < 10 && result > -10); // arbitrary bounds for success of test (false indicates success)
}
示例8: tag_location
bool tag_location( const std::string &filename, const location &loc)
{
bool result = false;
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open( filename);
if (!image.get()) throw std::runtime_error( "could not open image file " + filename + " for metadata tags\n");
image->readMetadata();
Exiv2::ExifData data = image->exifData();
if (data.findKey( Exiv2::ExifKey("Exif.GPSInfo.GPSLatitude")) == data.end())
{
add_exif_coordinate( data, "Exif.GPSInfo.GPSLatitude", std::abs( loc.latitude));
add_exif_coordinate( data, "Exif.GPSInfo.GPSLongitude", std::abs( loc.longitude));
data["Exif.GPSInfo.GPSLatitudeRef"] = loc.latitude < 0 ? "S":"N";
data["Exif.GPSInfo.GPSLongitudeRef"] = loc.longitude < 0 ? "W":"E";
Exiv2::byte version[] = { 2, 0, 0, 0};
data["Exif.GPSInfo.GPSVersionID"].getValue()->read( version, 4, Exiv2::invalidByteOrder);
image->setExifData( data);
image->writeMetadata();
result = true;
}
return result;
}
示例9: print
void print(const std::string& file)
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
assert (image.get() != 0);
image->readMetadata();
Exiv2::ExifData &ed = image->exifData();
Exiv2::ExifData::const_iterator end = ed.end();
for (Exiv2::ExifData::const_iterator i = ed.begin(); i != end; ++i) {
std::cout << std::setw(45) << std::setfill(' ') << std::left
<< i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " "
<< std::setw(12) << std::setfill(' ') << std::left
<< i->ifdName() << " "
<< std::setw(9) << std::setfill(' ') << std::left
<< i->typeName() << " "
<< std::dec << std::setw(3)
<< std::setfill(' ') << std::right
<< i->count() << " "
<< std::dec << i->value()
<< "\n";
}
}
示例10: readExif
void ExifReaderWriter::readExif(QString pictureName)
{
Exiv2::Image::AutoPtr image = openExif(pictureName);
if(image.get() == 0)
return;
Exiv2::ExifData &exifData = image->exifData();
if (exifData.empty()) {
//qDebug() << "nejsou exif data";
emit(finished());
return;
}
//cteniGPS souradnic
double lat = readLatLon("Exif.GPSInfo.GPSLatitude", exifData);
double lon = readLatLon("Exif.GPSInfo.GPSLongitude", exifData);
double alt = readAltitude("Exif.GPSInfo.GPSAltitude", exifData);
if(lat < 1000 && lon<1000)
{
emit(setGps(lat, lon, alt));
}
////////////////////////////
QDateTime *dateTime = NULL;
//cteni data
if((dateTime = readExifDate(exifData,"Exif.Photo.DateTimeOriginal")) == NULL)
if((dateTime = readExifDate(exifData,"Exif.Image.DateTimeOriginal")) == NULL)
if((dateTime = readExifDate(exifData,"Exif.Photo.DateTimeDigitized")) == NULL)
dateTime = readExifDate(exifData,"Exif.Image.DateTime");
if(dateTime != NULL)
emit(setDateTime(*dateTime));
emit(finished());
return;
}
示例11: geotag_worker
void geotag_worker(wc_work_queue &wq, std::vector<GPXPoint> &gpxData) {
std::string fname;
// Grab a file from the work queue
while ((fname = wq.getFile()) != "") {
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fname.c_str());
if (image.get() == 0) continue;
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
if (exifData.empty()) {
std::string error = fname;
error += ": No Exif data found in the file";
throw Exiv2::Error(1, error);
}
std::string tmpTime = exifData["Exif.Photo.DateTimeOriginal"].toString();
auto tstamp = getImageTimeStamp(tmpTime);
size_t idx = 0;
bool foundIt = findClosest(gpxData, tstamp, idx);
if (!foundIt) {
std::cout << fname << " is not on the GPX track!\n";
continue;
} else {
std::cout << fname << " was at (" << std::setprecision(10) << gpxData[idx].lat << ", " << std::setprecision(10) << gpxData[idx].lon << ")\n";
}
clearGPSFields(exifData);
exifData["Exif.GPSInfo.GPSMapDatum"] = "WGS-84";
exifData["Exif.GPSInfo.GPSAltitude"] = Exiv2::Rational(gpxData[idx].ele * 1000, 1000);
exifData["Exif.GPSInfo.GPSAltitudeRef"] = Exiv2::byte(0);
// Convert the latitude to DDD*MM'SS.SSS" and set
int dd, mm;
double ss;
convertToDDMMSS(gpxData[idx].lat, dd, mm, ss);
if (gpxData[idx].lat<0) {
exifData["Exif.GPSInfo.GPSLatitudeRef"] = "S";
} else {
exifData["Exif.GPSInfo.GPSLatitudeRef"] = "N";
}
Exiv2::URationalValue::AutoPtr latitude(new Exiv2::URationalValue);
latitude->value_.push_back(std::make_pair(dd,1));
latitude->value_.push_back(std::make_pair(mm,1));
latitude->value_.push_back(std::make_pair(std::trunc(ss*10000)-1,10000));
auto latKey = Exiv2::ExifKey("Exif.GPSInfo.GPSLatitude");
exifData.add(latKey, latitude.get());
convertToDDMMSS(gpxData[idx].lon, dd, mm, ss);
Exiv2::URationalValue::AutoPtr longitude(new Exiv2::URationalValue);
if (gpxData[idx].lon<0) {
exifData["Exif.GPSInfo.GPSLongitudeRef"] = "W";
} else {
exifData["Exif.GPSInfo.GPSLongitudeRef"] = "E";
}
longitude->value_.push_back(std::make_pair(dd,1));
longitude->value_.push_back(std::make_pair(mm,1));
longitude->value_.push_back(std::make_pair(int(ss*10000)-1,10000));
auto longKey = Exiv2::ExifKey("Exif.GPSInfo.GPSLongitude");
exifData.add(longKey, longitude.get());
Exiv2::URationalValue::AutoPtr timestamp(new Exiv2::URationalValue);
timestamp->value_.push_back(std::make_pair(gpxData[idx].hour,1));
timestamp->value_.push_back(std::make_pair(gpxData[idx].minute,1));
timestamp->value_.push_back(std::make_pair(gpxData[idx].second,1));
auto timeKey = Exiv2::ExifKey("Exif.GPSInfo.GPSTimeStamp");
exifData.add(timeKey, timestamp.get());
exifData["Exif.GPSInfo.GPSDateStamp"] = gpxData[idx].dateStamp.c_str();
image->setExifData(exifData);
image->writeMetadata();
}
catch (Exiv2::AnyError& e) {
std::cout << "Caught Exiv2 exception '" << e.what() << "'\n";
continue;
}
}
}
示例12: WriteFixedDatestamp
int WriteFixedDatestamp(const char* File, time_t Time)
{
// Write the GPS data to the file...
struct stat statbuf;
struct stat statbuf2;
struct utimbuf utb;
stat(File, &statbuf);
Exiv2::Image::AutoPtr Image;
try {
Image = Exiv2::ImageFactory::open(File);
} catch (Exiv2::Error e) {
DEBUGLOG("Failed to open file %s.\n", File);
return 0;
}
Image->readMetadata();
if (Image.get() == NULL)
{
// It failed if we got here.
DEBUGLOG("Failed to read file %s %s.\n",
File, Exiv2::strError().c_str());
return 0;
}
Exiv2::ExifData &ExifToWrite = Image->exifData();
const struct tm TimeStamp = *gmtime(&Time);
char ScratchBuf[100];
snprintf(ScratchBuf, sizeof(ScratchBuf), "%04d:%02d:%02d",
TimeStamp.tm_year + 1900,
TimeStamp.tm_mon + 1,
TimeStamp.tm_mday);
ExifToWrite.erase(ExifToWrite.findKey(Exiv2::ExifKey("Exif.GPSInfo.GPSDateStamp")));
ExifToWrite["Exif.GPSInfo.GPSDateStamp"] = ScratchBuf;
Exiv2::Value::AutoPtr Value = Exiv2::Value::create(Exiv2::unsignedRational);
snprintf(ScratchBuf, sizeof(ScratchBuf), "%d/1 %d/1 %d/1",
TimeStamp.tm_hour, TimeStamp.tm_min,
TimeStamp.tm_sec);
Value->read(ScratchBuf);
ExifToWrite.erase(ExifToWrite.findKey(Exiv2::ExifKey("Exif.GPSInfo.GPSTimeStamp")));
ExifToWrite.add(Exiv2::ExifKey("Exif.GPSInfo.GPSTimeStamp"), Value.get());
try {
Image->writeMetadata();
} catch (Exiv2::Error e) {
DEBUGLOG("Failed to write to file %s.\n", File);
return 0;
}
// Reset the mtime.
stat(File, &statbuf2);
utb.actime = statbuf2.st_atime;
utb.modtime = statbuf.st_mtime;
utime(File, &utb);
return 1;
}
示例13: WriteGPSData
int WriteGPSData(const char* File, const struct GPSPoint* Point,
const char* Datum, int NoChangeMtime, int DegMinSecs)
{
// Write the GPS data to the file...
struct stat statbuf;
struct stat statbuf2;
struct utimbuf utb;
if (NoChangeMtime)
stat(File, &statbuf);
Exiv2::Image::AutoPtr Image;
try {
Image = Exiv2::ImageFactory::open(File);
} catch (Exiv2::Error e) {
DEBUGLOG("Failed to open file %s.\n", File);
return 0;
}
Image->readMetadata();
if (Image.get() == NULL)
{
// It failed if we got here.
DEBUGLOG("Failed to read file %s %s.\n",
File, Exiv2::strError().c_str());
return 0;
}
Exiv2::ExifData &ExifToWrite = Image->exifData();
// Make sure we're starting from a clean GPS IFD.
// There might be lots of GPS tags existing here, since only the
// presence of the GPSLatitude tag causes correlation to stop with
// "GPS Already Present" error.
EraseGpsTags(ExifToWrite);
char ScratchBuf[100];
// Do all the easy constant ones first.
// GPSVersionID tag: standard says it should be four bytes: 02 02 00 00
// (and, must be present).
Exiv2::Value::AutoPtr Value = Exiv2::Value::create(Exiv2::unsignedByte);
Value->read("2 2 0 0");
ExifToWrite.add(Exiv2::ExifKey("Exif.GPSInfo.GPSVersionID"), Value.get());
// Datum: the datum of the measured data. The default is WGS-84.
if (*Datum)
ExifToWrite["Exif.GPSInfo.GPSMapDatum"] = Datum;
// Now start adding data.
// ALTITUDE.
// If no altitude was found in the GPX file, ElevDecimals will be -1
if (Point->ElevDecimals >= 0) {
// Altitude reference: byte "00" meaning "sea level".
// Or "01" if the altitude value is negative.
Value = Exiv2::Value::create(Exiv2::unsignedByte);
if (Point->Elev >= 0)
{
Value->read("0");
} else {
Value->read("1");
}
ExifToWrite.add(Exiv2::ExifKey("Exif.GPSInfo.GPSAltitudeRef"), Value.get());
// And the actual altitude.
Value = Exiv2::Value::create(Exiv2::unsignedRational);
// 3 decimal points is beyond the limit of current GPS technology
int Decimals = MIN(Point->ElevDecimals, 3);
ConvertToRational(fabs(Point->Elev), Decimals, ScratchBuf, sizeof(ScratchBuf));
/* printf("Altitude: %f -> %s\n", Point->Elev, ScratchBuf); */
Value->read(ScratchBuf);
ExifToWrite.add(Exiv2::ExifKey("Exif.GPSInfo.GPSAltitude"), Value.get());
}
// LATITUDE
// Latitude reference: "N" or "S".
if (Point->Lat < 0)
{
// Less than Zero: ie, minus: means
// Southern hemisphere. Where I live.
ExifToWrite["Exif.GPSInfo.GPSLatitudeRef"] = "S";
} else {
// More than Zero: ie, plus: means
// Northern hemisphere.
ExifToWrite["Exif.GPSInfo.GPSLatitudeRef"] = "N";
}
// Now the actual latitude itself.
// The original comment read:
// This is done as three rationals.
// I choose to do it as:
// dd/1 - degrees.
// mmmm/100 - minutes
// 0/1 - seconds
// Exif standard says you can do it with minutes
// as mm/1 and then seconds as ss/1, but its
// (slightly) more accurate to do it as
// mmmm/100 than to split it.
// We also absolute the value (with fabs())
// as the sign is encoded in LatRef.
// Further note: original code did not translate between
// dd.dddddd to dd mm.mm - that's why we now multiply
// by 60*N - x60 to get minutes, xN to get to mmmm/N.
//.........这里部分代码省略.........
示例14: ReadGPSTimestamp
// This function is for the --fix-datestamp option.
// DateStamp and TimeStamp should be 12-char strings.
char* ReadGPSTimestamp(const char* File, char* DateStamp, char* TimeStamp, int* IncludesGPS)
{
// This function varies in that it reads
// much more data than the last, specifically
// for display purposes. For the GUI version.
// Open and read the file.
Exiv2::Image::AutoPtr Image;
try {
Image = Exiv2::ImageFactory::open(File);
} catch (Exiv2::Error e) {
DEBUGLOG("Failed to open file %s.\n", File);
return NULL;
}
Image->readMetadata();
if (Image.get() == NULL)
{
DEBUGLOG("Failed to read file %s %s.\n",
File, Exiv2::strError().c_str());
return NULL;
}
Exiv2::ExifData &ExifRead = Image->exifData();
// Read the tag out.
Exiv2::Exifdatum& Tag = ExifRead["Exif.Photo.DateTimeOriginal"];
// Check that the tag is not blank.
std::string Value = Tag.toString();
if (Value.length() == 0)
{
// No date/time stamp.
// Not good.
// Just return - above us will handle it.
return NULL;
}
// Copy the tag and return that.
char* Copy = strdup(Value.c_str());
// Check if we have GPS tags.
Exiv2::Exifdatum& GPSData = ExifRead["Exif.GPSInfo.GPSVersionID"];
Value = GPSData.toString();
if (Value.length() == 0)
{
// No GPS data.
// Just return.
*IncludesGPS = 0;
} else {
// Seems to include GPS data...
*IncludesGPS = 1;
Exiv2::URational RatNum1;
Exiv2::URational RatNum2;
Exiv2::URational RatNum3;
// Read out the Time and Date stamp, for correction.
GPSData = ExifRead["Exif.GPSInfo.GPSTimeStamp"];
if (GPSData.count() < 3) {
*IncludesGPS = 0;
return Copy;
}
RatNum1 = GPSData.toRational(0);
RatNum2 = GPSData.toRational(1);
RatNum3 = GPSData.toRational(2);
snprintf(TimeStamp, 12, "%02d:%02d:%02d",
RatNum1.first, RatNum2.first, RatNum3.first);
GPSData = ExifRead["Exif.GPSInfo.GPSDateStamp"];
if (GPSData.count() < 3) {
*IncludesGPS = 0;
return Copy;
}
if (GPSData.typeId() == Exiv2::signedRational) {
// bad type written by old gpscorrelate versions
RatNum1 = GPSData.toRational(0);
RatNum2 = GPSData.toRational(1);
RatNum3 = GPSData.toRational(2);
snprintf(DateStamp, 12, "%04d:%02d:%02d",
RatNum1.first, RatNum2.first, RatNum3.first);
} else
snprintf(DateStamp, 12, "%s", GPSData.toString().c_str());
}
return Copy;
}
示例15: ReadExifData
char* ReadExifData(const char* File, double* Lat, double* Long, double* Elev, int* IncludesGPS)
{
// This function varies in that it reads
// much more data than the last, specifically
// for display purposes. For the GUI version.
// Open and read the file.
Exiv2::Image::AutoPtr Image;
try {
Image = Exiv2::ImageFactory::open(File);
} catch (Exiv2::Error e) {
DEBUGLOG("Failed to open file %s.\n", File);
return NULL;
}
Image->readMetadata();
if (Image.get() == NULL)
{
DEBUGLOG("Failed to read file %s %s.\n",
File, Exiv2::strError().c_str());
return NULL;
}
Exiv2::ExifData &ExifRead = Image->exifData();
// Read the tag out.
Exiv2::Exifdatum& Tag = ExifRead["Exif.Photo.DateTimeOriginal"];
// Check that the tag is not blank.
std::string Value = Tag.toString();
if (Value.length() == 0)
{
// No date/time stamp.
// Not good.
// Just return - above us will handle it.
return NULL;
}
// Copy the tag and return that.
char* Copy = strdup(Value.c_str());
// Check if we have GPS tags.
Exiv2::Exifdatum GPSData = ExifRead["Exif.GPSInfo.GPSVersionID"];
Value = GPSData.toString();
if (Value.length() == 0)
{
// No GPS data.
// Just return.
*IncludesGPS = 0;
} else {
// Seems to include GPS data...
*IncludesGPS = 1;
// Read it out and send it up!
// What we are trying to do here is convert the
// three rationals:
// dd/v mm/v ss/v
// To a decimal
// dd.dddddd...
// dd/v is easy: result = dd/v.
// mm/v is harder:
// mm
// -- / 60 = result.
// v
// ss/v is sorta easy.
// ss
// -- / 3600 = result
// v
// Each part is added to the final number.
Exiv2::URational RatNum;
GPSData = ExifRead["Exif.GPSInfo.GPSLatitude"];
if (GPSData.count() < 3)
*Lat = nan("invalid");
else {
RatNum = GPSData.toRational(0);
*Lat = (double)RatNum.first / (double)RatNum.second;
RatNum = GPSData.toRational(1);
*Lat = *Lat + (((double)RatNum.first / (double)RatNum.second) / 60);
RatNum = GPSData.toRational(2);
*Lat = *Lat + (((double)RatNum.first / (double)RatNum.second) / 3600);
GPSData = ExifRead["Exif.GPSInfo.GPSLatitudeRef"];
if (strcmp(GPSData.toString().c_str(), "S") == 0)
{
// Negate the value - Western Hemisphere.
*Lat = -*Lat;
}
}
GPSData = ExifRead["Exif.GPSInfo.GPSLongitude"];
if (GPSData.count() < 3)
*Long = nan("invalid");
else {
RatNum = GPSData.toRational(0);
*Long = (double)RatNum.first / (double)RatNum.second;
RatNum = GPSData.toRational(1);
*Long = *Long + (((double)RatNum.first / (double)RatNum.second) / 60);
RatNum = GPSData.toRational(2);
//.........这里部分代码省略.........