本文整理汇总了C++中exiv2::exifdata::const_iterator::tagName方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::tagName方法的具体用法?C++ const_iterator::tagName怎么用?C++ const_iterator::tagName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exiv2::exifdata::const_iterator
的用法示例。
在下文中一共展示了const_iterator::tagName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: updateExifInfo
void ThumbView::updateExifInfo(QString imageFullPath)
{
Exiv2::Image::AutoPtr exifImage;
QString key;
QString val;
try {
exifImage = Exiv2::ImageFactory::open(imageFullPath.toStdString());
exifImage->readMetadata();
}
catch (Exiv2::Error &error) {
return;
}
Exiv2::ExifData &exifData = exifImage->exifData();
if (!exifData.empty()) {
Exiv2::ExifData::const_iterator end = exifData.end();
infoView->addTitleEntry("Exif");
for (Exiv2::ExifData::const_iterator md = exifData.begin(); md != end; ++md) {
key = QString::fromUtf8(md->tagName().c_str());
val = QString::fromUtf8(md->print().c_str());
infoView->addEntry(key, val);
}
}
Exiv2::IptcData &iptcData = exifImage->iptcData();
if (!iptcData.empty()) {
Exiv2::IptcData::iterator end = iptcData.end();
infoView->addTitleEntry("IPTC");
for (Exiv2::IptcData::iterator md = iptcData.begin(); md != end; ++md) {
key = QString::fromUtf8(md->tagName().c_str());
val = QString::fromUtf8(md->print().c_str());
infoView->addEntry(key, val);
}
}
Exiv2::XmpData &xmpData = exifImage->xmpData();
if (!xmpData.empty()) {
Exiv2::XmpData::iterator end = xmpData.end();
infoView->addTitleEntry("XMP");
for (Exiv2::XmpData::iterator md = xmpData.begin(); md != end; ++md) {
key = QString::fromUtf8(md->tagName().c_str());
val = QString::fromUtf8(md->print().c_str());
infoView->addEntry(key, val);
}
}
}
示例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: LOG
/** \fn ImageUtils::GetAllExifValues(const QString &)
* \brief Reads and returns all non empty tags from the given file
* \param fileName The filename that holds the exif data
* \return The list of exif tag names and values
*/
QList<QStringList> ImageUtils::GetAllExifValues(const QString &fileName)
{
// default value, an empty list means no
// exif tags were found or an error occured
QList<QStringList> valueList;
try
{
Exiv2::Image::AutoPtr image =
Exiv2::ImageFactory::open(fileName.toLocal8Bit().constData());
if (image.get())
{
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
if (!exifData.empty())
{
LOG(VB_GENERAL, LOG_DEBUG,
QString("Found %1 tag(s) for file %2")
.arg(exifData.count())
.arg(fileName));
Exiv2::ExifData::const_iterator end = exifData.end();
Exiv2::ExifData::const_iterator i = exifData.begin();
for (; i != end; ++i)
{
QString value = QString::fromStdString(i->value().toString());
// Do not add empty tags to the list
if (!value.isEmpty())
{
QStringList values;
// These three are the same as i->key()
values.append(QString::fromStdString(i->familyName()));
values.append(QString::fromStdString(i->groupName()));
values.append(QString::fromStdString(i->tagName()));
values.append(QString::fromStdString(i->key()));
values.append(QString::fromStdString(i->tagLabel()));
values.append(QString::fromStdString(i->value().toString()));
// Add the exif information to the list
valueList.append(values);
}
}
}
else
{
LOG(VB_GENERAL, LOG_ERR,
QString("Exiv2 error: No header, file %1")
.arg(fileName));
}
}
else
{
LOG(VB_GENERAL, LOG_ERR,
QString("Exiv2 error: Could not open file, file %1")
.arg(fileName));
}
}
catch (Exiv2::Error& e)
{
LOG(VB_GENERAL, LOG_ERR,
QString("Exiv2 exception %1, file %2")
.arg(e.what()).arg(fileName));
}
return valueList;
}
示例5: JMAP
JSONNODE *ImgTagJson::genLitExif(const Exiv2::Image::AutoPtr & image)
{
//const Exiv2::ExifData &data = image->exifData();
Exiv2::ExifData &data = image->exifData();
data.sortByKey();
if (data.empty()) return NULL;
Exiv2::ExifData::const_iterator end = data.end();
JMAP *grpmap = new JMAP();
JSONNODE *tree = json_new(JSON_NODE);
json_set_name(tree, "exif");
for (Exiv2::ExifData::const_iterator i = data.begin(); i != end; i++)
{
JSONNODE *grp;
if (grpmap->find(i->groupName()) == grpmap->end())
{
grp = json_new(JSON_NODE);
json_set_name(grp, i->groupName().c_str());
grpmap->insert(JMAP::value_type(i->groupName(), grp));
}
else
grp = (grpmap->find(i->groupName()))->second;
Exiv2::ExifData::const_iterator nxt = i;
nxt++;
if ((nxt != data.end()) && (i->key() == nxt->key()))
{
//cout << "Array Elem! " << i->key() << endl;
JSONNODE *arr = json_new(JSON_ARRAY);
json_set_name(arr, i->tagName().c_str());
json_push_back(arr, json_new_a((i->tagName()).c_str(),
(i->print()).c_str()));
while ((nxt != data.end()) && (nxt->key() == i->key()))
{
json_push_back(arr, json_new_a((nxt->tagName()).c_str(),
(nxt->print()).c_str()));
nxt++;
}
json_push_back(grp, arr);
if (nxt == data.end()) break;
nxt--;
i = nxt;
}
else
{
json_push_back(grp, json_new_a((i->tagName()).c_str(),
(i->print()).c_str()));
}
}
JMAP::iterator it;
for(it = grpmap->begin(); it != grpmap->end(); it++)
{
json_push_back(tree, it->second);
grpmap->erase(it);
}
//cout << it->first << endl;
delete grpmap;
//cout << json_write_formatted(tree) << endl;
return tree;
}