当前位置: 首页>>代码示例>>C++>>正文


C++ exiv2::ExifData类代码示例

本文整理汇总了C++中exiv2::ExifData的典型用法代码示例。如果您正苦于以下问题:C++ ExifData类的具体用法?C++ ExifData怎么用?C++ ExifData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ExifData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>&emsp;" +
                      //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


注:本文中的exiv2::ExifData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。