本文整理汇总了C++中exiv2::ExifData类的典型用法代码示例。如果您正苦于以下问题:C++ ExifData类的具体用法?C++ ExifData怎么用?C++ ExifData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExifData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: exifDataToString
QString exifDataToString(Exiv2::ExifData exifData) {
if (exifData.empty()) {
return QString(QObject::tr("No EXIF found"));
}
try {
Exiv2::ExifData::const_iterator end = exifData.end();
QString tmpExif, final;
for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
const char* tn = i->typeName();
/*std::string str = i->key() << " ";
<< "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left
<< (tn ? tn : "Unknown") << " "
<< std::dec << std::setw(3)
<< std::setfill(' ') << std::right
<< i->count() << " "
<< std::dec << i->value()
<< "\n";*/
tmpExif = "<span style='color:#1cb495;'>" + QString::fromStdString(i->key()).split(".").at(2) + "</span> " +
//QString::number(i->tag()) + "\t" +
//(tn ? tn : "Unknown") + "\t" +
//QString::number(i->count()) + "\t" +
QString::fromStdString(i->value().toString()) + "<br />";
final.append(tmpExif);
}
return final;
} catch(Exiv2::Error& e) {
开发者ID:Lymphatus,项目名称:caesium-image-compressor,代码行数:28,代码来源:exif.cpp
示例2: print
void print(const std::string& file)
{
Exiv2::ExifData ed;
int rc = ed.read(file);
if (rc) {
std::string error = Exiv2::ExifData::strError(rc, file);
throw Exiv2::Error(error);
}
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";
}
}
开发者ID:obklar,项目名称:exiv2,代码行数:27,代码来源:write2-test.cpp
示例3: orientationToAngle
void DB::FileInfo::parseEXIV2( const DB::FileName& fileName )
{
Exiv2::ExifData map = Exif::Info::instance()->metadata( fileName ).exif;
// Date
m_date = fetchEXIV2Date( map, "Exif.Photo.DateTimeOriginal" );
if ( !m_date.isValid() ) {
m_date = fetchEXIV2Date( map, "Exif.Photo.DateTimeDigitized" );
if ( !m_date.isValid() )
m_date = fetchEXIV2Date( map, "Exif.Image.DateTime" );
}
// Angle
if ( map.findKey( Exiv2::ExifKey( "Exif.Image.Orientation" ) ) != map.end() ) {
const Exiv2::Exifdatum& datum = map["Exif.Image.Orientation"];
int orientation = 0;
if (datum.count() > 0)
orientation = datum.toLong();
m_angle = orientationToAngle( orientation );
}
// Description
if( map.findKey( Exiv2::ExifKey( "Exif.Image.ImageDescription" ) ) != map.end() ) {
const Exiv2::Exifdatum& datum = map["Exif.Image.ImageDescription"];
m_description = QString::fromLocal8Bit( datum.toString().c_str() );
}
}
开发者ID:astifter,项目名称:kphotoalbum-astifter-branch,代码行数:28,代码来源:FileInfo.cpp
示例4: getExifDateTime
bool getExifDateTime(Exiv2::ExifData &exifData, QDateTime &dateTime) {
bool anyFound = false;
try {
Exiv2::ExifKey key(EXIF_PHOTO_DATETIMEORIGINAL);
Exiv2::ExifData::iterator it = exifData.findKey(key);
if (it != exifData.end()) {
dateTime = QDateTime::fromString(QString::fromLatin1(it->toString().c_str()), Qt::ISODate);
anyFound = dateTime.isValid();
}
if (!anyFound) {
Exiv2::ExifKey imageKey(EXIF_IMAGE_DATETIMEORIGINAL);
Exiv2::ExifData::iterator imageIt = exifData.findKey(imageKey);
if (imageIt != exifData.end()) {
dateTime = QDateTime::fromString(QString::fromLatin1(imageIt->toString().c_str()), Qt::ISODate);
anyFound = dateTime.isValid();
}
}
}
catch (Exiv2::Error &e) {
LOG_WARNING << "Exiv2 error:" << e.what();
anyFound = false;
}
catch (...) {
LOG_WARNING << "Exception";
anyFound = false;
#ifdef QT_DEBUG
throw;
#endif
}
return anyFound;
}
开发者ID:RostaTasha,项目名称:xpiks,代码行数:34,代码来源:exiv2readingworker.cpp
示例5: HasExifKey
/** \fn ImageUtils::HasExifKey(Exiv2::ExifData, const QString &)
* \brief Checks if the exif data of the file contains the given key
* \param exifData The entire exif data
* \param exifTag The key that shall be checked
* \return True if the exif key exists, otherwise false
*/
bool ImageUtils::HasExifKey(Exiv2::ExifData exifData,
const QString &exifTag)
{
Exiv2::ExifKey key(exifTag.toLocal8Bit().constData());
Exiv2::ExifData::iterator it = exifData.findKey(key);
// If the iterator has is the end of the
// list then the key has not been found
return !(it == exifData.end());
}
开发者ID:,项目名称:,代码行数:16,代码来源:
示例6:
bool _getExiv2Value(Exiv2::ExifData& exifData, std::string keyName, float & value)
{
Exiv2::ExifData::iterator itr = exifData.findKey(Exiv2::ExifKey(keyName));
if (itr != exifData.end() && itr->count())
{
value = itr->toFloat();
return true;
}
else
{
return false;
};
};
开发者ID:ndevenish,项目名称:Hugin,代码行数:13,代码来源:Exiv2Helper.cpp
示例7: EraseGpsTags
static void EraseGpsTags(Exiv2::ExifData &ExifInfo)
{
// Search through, find the keys that we want, and wipe them
// Code below submitted by Marc Horowitz
Exiv2::ExifData::iterator Iter;
for (Exiv2::ExifData::iterator Iter = ExifInfo.begin();
Iter != ExifInfo.end(); )
{
if (Iter->key().find("Exif.GPSInfo") == 0)
Iter = ExifInfo.erase(Iter);
else
Iter++;
}
}
开发者ID:bruniii,项目名称:gpscorrelate,代码行数:14,代码来源:exif-gps.cpp
示例8: fromString
QDateTime FileInfo::fetchEXIV2Date( Exiv2::ExifData& map, const char* key )
{
try
{
if ( map.findKey( Exiv2::ExifKey( key ) ) != map.end() ) {
const Exiv2::Exifdatum& datum = map[key ];
return QDateTime::fromString( QString::fromLatin1(datum.toString().c_str()), Qt::ISODate );
}
}
catch (...)
{
}
return QDateTime();
}
开发者ID:astifter,项目名称:kphotoalbum-astifter-branch,代码行数:15,代码来源:FileInfo.cpp
示例9: showExifData
// uses the exiv2 class to readout the exifdata from images
int ExifScout::showExifData(std::string a){
try {
Ui_MainWindow::textEdit->clear();
std::cerr << "ImageFactory::open ";
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(a);
std::cerr << "DONE\n";
assert(image.get() != 0);
std::cerr << "image->readMetadata() ";
image->readMetadata();
std::cerr << "DONE\n";
std::cerr << "Exiv2::ExifData& exifData = image->exifData() ";
Exiv2::ExifData exifData = image->exifData();
std::cerr << "DONE\n";
cout << "Number of found exiv2 data: " << exifData.count() << endl;
if (exifData.empty()) {
Ui_MainWindow::textEdit->setPlainText("No Exif data found in file");
return 1;
}
Exiv2::ExifData::const_iterator end = exifData.end();
std::cerr << "Generate the exif-output ";
QString output;
for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
std::string tagname = i->tagName();
if(tagname != std::string("MakerNote") and
tagname.substr(0,2) != "0x"){
// Print out the exif-data in the QtextEdit Field
std::ostringstream oss;
oss << i->tagName() << ":\n " << i->value() << "\n";
output = output+(QString)oss.str().c_str();
}
}
std::cerr << "Done\n";
Ui_MainWindow::textEdit->setPlainText(output);
return 0;
}
//catch (std::exception& e) {
//catch (Exiv2::AnyError& e) {
catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e.what() << "'\n";
return -1;
}
}
开发者ID:hypergnash,项目名称:Exif-Scout,代码行数:49,代码来源:exif-scout_window.cpp
示例10: StrTrim
const std::string getExiv2ValueString(Exiv2::ExifData& exifData,Exiv2::ExifData::const_iterator it)
{
if(it!=exifData.end() && it->count())
{
return hugin_utils::StrTrim(it->toString());
};
return std::string("");
};
开发者ID:ndevenish,项目名称:Hugin,代码行数:8,代码来源:Exiv2Helper.cpp
示例11: write
void write(const std::string& file, Exiv2::ExifData& ed)
{
int rc = ed.write(file);
if (rc) {
std::string error = Exiv2::ExifData::strError(rc, file);
throw Exiv2::Error(error);
}
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例12: readExifItem
QString ExifReaderWriter::readExifItem( Exiv2::ExifData &exifData, std::string keyStr)
{
try{
Exiv2::ExifKey key(keyStr);
Exiv2::ExifData::iterator pos = exifData.findKey(key);
if(pos != exifData.end())
{
return exifData[keyStr].toString().data();
}
}
catch (Exiv2::Error& e) {
;//std::cerr << "Caught Exiv2 exception '" << e.what() << "'\n";
}
return "";
}
开发者ID:jmlich,项目名称:geotagging,代码行数:17,代码来源:exifreaderwriter.cpp
示例13: writeData
void ExifReaderWriter::writeData(Exiv2::ExifData &exifData, std::string keyStr, QString str)
{
try{
Exiv2::ExifKey key(keyStr);
Exiv2::ExifData::iterator pos = exifData.findKey(key);
if(pos != exifData.end()){
exifData[keyStr].setValue(str.toStdString());
}
else //vytvorim novou polozku
{
exifData[keyStr].setValue(str.toStdString());
}
}
catch (Exiv2::Error& e) {
;//std::cerr << "Caught Exiv2 exception '" << e.what() << "'\n";
}
}
开发者ID:jmlich,项目名称:geotagging,代码行数:19,代码来源:exifreaderwriter.cpp
示例14: getExifCommentValue
QString getExifCommentValue(Exiv2::ExifData &exifData, const char *propertyName) {
QString result;
Exiv2::ExifKey key(propertyName);
Exiv2::ExifData::iterator it = exifData.findKey(key);
if (it != exifData.end()) {
const Exiv2::Exifdatum& exifDatum = *it;
std::string comment;
std::string charset;
comment = exifDatum.toString();
// libexiv2 will prepend "charset=\"SomeCharset\" " if charset is specified
// Before conversion to QString, we must know the charset, so we stay with std::string for a while
if (comment.length() > 8 && comment.substr(0, 8) == "charset=") {
// the prepended charset specification is followed by a blank
std::string::size_type pos = comment.find_first_of(' ');
if (pos != std::string::npos) {
// extract string between the = and the blank
charset = comment.substr(8, pos-8);
// get the rest of the string after the charset specification
comment = comment.substr(pos+1);
}
}
if (charset == "\"Unicode\"") {
result = QString::fromUtf8(comment.data());
}
else if (charset == "\"Jis\"") {
QTextCodec* const codec = QTextCodec::codecForName("JIS7");
result = codec->toUnicode(comment.c_str());
}
else if (charset == "\"Ascii\"") {
result = QString::fromLatin1(comment.c_str());
} else {
result = Helpers::detectEncodingAndDecode(comment);
}
}
return result;
}
开发者ID:RostaTasha,项目名称:xpiks,代码行数:43,代码来源:exiv2readingworker.cpp
示例15: 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;
}
开发者ID:hypergnash,项目名称:Exif-Scout,代码行数:22,代码来源:exif-scout_window.cpp
示例16: clearGPSFields
void clearGPSFields(Exiv2::ExifData &exifData) {
std::list<std::string> fields = {"Exif.GPSInfo.GPSLatitude",
"Exif.GPSInfo.GPSLongitude",
"Exif.GPSInfo.GPSMapDatum",
"Exif.GPSInfo.GPSLatitudeRef",
"Exif.GPSInfo.GPSLongitudeRef",
"Exif.GPSInfo.GPSLatitude",
"Exif.GPSInfo.GPSLongitude",
"Exif.GPSInfo.GPSAltitude",
"Exif.GPSInfo.GPSAltitudeRef",
"Exif.GPSInfo.GPSTimeStamp",
"Exif.GPSInfo.GPSDateStamp",};
for (auto fname : fields) {
auto key = Exiv2::ExifKey(fname.c_str());
auto iter = exifData.findKey(key);
while (iter != exifData.end()) {
exifData.erase(iter);
iter = exifData.findKey(key);
}
}
}
开发者ID:jl2,项目名称:geotagger,代码行数:23,代码来源:main.cpp
示例17: 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;
}
开发者ID:DannyHavenith,项目名称:EyeFiGeotagger,代码行数:23,代码来源:exif_tagging.cpp
示例18: add_exif_coordinate
void add_exif_coordinate( Exiv2::ExifData &data, const std::string &attribute, double value)
{
Exiv2::URationalValue::AutoPtr rational(new Exiv2::URationalValue);
// Add more elements through the extended interface of rational value
double frac = 0.0;
double intpart = 0.0;
frac = std::modf( value, &intpart);
rational->value_.push_back(std::make_pair( (unsigned int)intpart, (unsigned int)1));
// intpart = minutes * 10000
frac = std::modf( frac * 600000, &intpart);
rational->value_.push_back(std::make_pair( (unsigned int)intpart, (unsigned int)10000));
rational->value_.push_back(std::make_pair(0,1));
// Add the key and value pair to the Exif data
Exiv2::ExifKey key = Exiv2::ExifKey( attribute);
data.add(key, rational.get());
}
开发者ID:DannyHavenith,项目名称:EyeFiGeotagger,代码行数:20,代码来源:exif_tagging.cpp
示例19: string
const std::string getLensName(Exiv2::ExifData &exifData)
{
std::string lensName;
// first we are reading LensModel in Exif section, this is only available
// with EXIF >= 2.3
#if EXIV2_TEST_VERSION(0,22,0)
//the string "Exif.Photo.LensModel" is only defined in exiv2 0.22.0 and above
if(_getExiv2Value(exifData, "Exif.Photo.LensModel", lensName))
#else
if(_getExiv2Value(exifData, 0xa434, "Photo", lensName))
#endif
{
if(lensName.length()>0)
{
return lensName;
};
}
else
{
//no lens in Exif found, now look in makernotes
Exiv2::ExifData::const_iterator itr2 = Exiv2::lensName(exifData);
if (itr2!=exifData.end() && itr2->count())
{
//we are using prettyPrint function to get string of lens name
//it2->toString returns for many cameras only an ID number
lensName=itr2->print(&exifData);
//check returned lens name
if(lensName.length()>0)
{
//for Canon it can contain (65535) or (0) for unknown lenses
//for Pentax it can contain Unknown (0xHEX)
if(lensName.compare(0, 1, "(")!=0 && lensName.compare(0, 7, "Unknown")!=0)
{
return lensName;
}
};
};
};
return std::string("");
};
开发者ID:ndevenish,项目名称:Hugin,代码行数:40,代码来源:Exiv2Helper.cpp
示例20: GetNaturalRotation
long GalleryUtil::GetNaturalRotation(const QString &filePathString)
{
long rotateAngle = 0;
#ifdef EXIF_SUPPORT
QByteArray filePathBA = filePathString.toLocal8Bit();
const char *filePath = filePathBA.constData();
try
{
char *exifvalue = new char[1024];
ExifData *data = exif_data_new_from_file (filePath);
if (data)
{
for (int i = 0; i < EXIF_IFD_COUNT; i++)
{
ExifEntry *entry = exif_content_get_entry (data->ifd[i],
EXIF_TAG_ORIENTATION);
ExifByteOrder byteorder = exif_data_get_byte_order (data);
if (entry)
{
ExifShort v_short = exif_get_short (entry->data, byteorder);
VERBOSE(VB_GENERAL|VB_EXTRA, QString("Exif entry=%1").arg(v_short));
/* See http://sylvana.net/jpegcrop/exif_orientation.html*/
if (v_short == 8)
{
rotateAngle = -90;
}
else if (v_short == 6)
{
rotateAngle = 90;
}
break;
}
}
exif_data_free(data);
}
else
{
VERBOSE(VB_FILE, LOC_ERR +
QString("Could not load exif data from '%1'")
.arg(filePath));
}
delete [] exifvalue;
#if 0
Exiv2::ExifData exifData;
int rc = exifData.read(filePath);
if (!rc)
{
Exiv2::ExifKey key = Exiv2::ExifKey("Exif.Image.Orientation");
Exiv2::ExifData::iterator pos = exifData.findKey(key);
if (pos != exifData.end())
{
long orientation = pos->toLong();
switch (orientation)
{
case 6:
rotateAngle = 90;
break;
case 8:
rotateAngle = -90;
break;
default:
rotateAngle = 0;
break;
}
}
}
#endif
}
catch (...)
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
QString("Failed to extract EXIF headers from '%1'")
.arg(filePathString));
}
#else
// Shut the compiler up about the unused argument
(void)filePathString;
#endif // EXIF_SUPPORT
return rotateAngle;
}
开发者ID:Openivo,项目名称:mythtv,代码行数:85,代码来源:galleryutil.cpp
注:本文中的exiv2::ExifData类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论