From 175b8cb59fc3aed0a8ed5a39672d511eac797975 Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Mon, 4 Feb 2019 16:32:28 +0100 Subject: [PATCH] initial commit --- cexif.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++ cexif.h | 15 +++++++++++++++ cmainwindow.cpp | 6 ++++++ pictureLibrary.pro | 6 ++++-- 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 cexif.cpp create mode 100644 cexif.h diff --git a/cexif.cpp b/cexif.cpp new file mode 100644 index 0000000..f6727cb --- /dev/null +++ b/cexif.cpp @@ -0,0 +1,48 @@ +#include "cexif.h" + +#include + +#include + + +cEXIF::cEXIF() +{ +} + +bool cEXIF::fromFile(const QString& szFileName) +{ + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(szFileName.toStdString()); + if(!image.get()) + return(false); + + image->readMetadata(); + + Exiv2::ExifData& exifData = image->exifData(); + if(exifData.empty()) + return(false); + + Exiv2::ExifData::const_iterator end = exifData.end(); + for(Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) + { + const char* tn = i->typeName(); + std::string str; + std::stringstream strBuffer; + + strBuffer << std::setw(44) << std::setfill(' ') << std::left + << 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(); + + str = strBuffer.str(); + + qDebug() << str.data(); + } + + return(true); +} diff --git a/cexif.h b/cexif.h new file mode 100644 index 0000000..5063be1 --- /dev/null +++ b/cexif.h @@ -0,0 +1,15 @@ +#ifndef CEXIF_H +#define CEXIF_H + +#include + + +class cEXIF +{ +public: + cEXIF(); + + bool fromFile(const QString& szFileName); +}; + +#endif // CEXIF_H diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 9a9a230..6a9efc4 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -1,12 +1,18 @@ #include "cmainwindow.h" #include "ui_cmainwindow.h" +#include "cexif.h" + cMainWindow::cMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::cMainWindow) { ui->setupUi(this); + + cEXIF exif; + + exif.fromFile("C:/Users/VET0572/Pictures/IMG_1372.CR2"); } cMainWindow::~cMainWindow() diff --git a/pictureLibrary.pro b/pictureLibrary.pro index f7369aa..6505df0 100644 --- a/pictureLibrary.pro +++ b/pictureLibrary.pro @@ -48,10 +48,12 @@ CONFIG += c++11 SOURCES += \ main.cpp \ - cmainwindow.cpp + cmainwindow.cpp \ + cexif.cpp HEADERS += \ - cmainwindow.h + cmainwindow.h \ + cexif.h FORMS += \ cmainwindow.ui