本文整理汇总了C++中exiv2::ExifData::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ExifData::empty方法的具体用法?C++ ExifData::empty怎么用?C++ ExifData::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exiv2::ExifData
的用法示例。
在下文中一共展示了ExifData::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
示例2: 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;
}
}
示例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: openDirectory
int RenameMePhotos::openDirectory(std::string p, std::vector<std::pair<boost::filesystem::path, time_t> > &vec, bool recursive, bool clear)
{
if(clear)
{
vec.clear();
}
// Var Declaration
struct tm t;
std::vector<boost::filesystem::path> vecTmp;
std::pair<boost::filesystem::path, time_t> file;
std::string strTmp;
time_t timestamp;
boost::filesystem::path path(p);
Exiv2::ExifData exifData;
Exiv2::Image::AutoPtr image;
// Body
if(exists(path))
{
if(is_directory(path))
{
if(recursive)
{
std::copy(boost::filesystem::recursive_directory_iterator(path), boost::filesystem::recursive_directory_iterator(), std::back_inserter(vecTmp));
}
else
{
std::copy(boost::filesystem::directory_iterator(path), boost::filesystem::directory_iterator(), std::back_inserter(vecTmp));
}
for(std::vector<boost::filesystem::path>::const_iterator it(vecTmp.begin()); it != vecTmp.end(); it++)
{
if(!is_directory(*it))
{
image = Exiv2::ImageFactory::open((*it).c_str());
if(image.get() != 0)
{
image->readMetadata();
exifData = image->exifData();
if(!exifData.empty())
{
strTmp = exifData["Exif.Photo.DateTimeOriginal"].toString();
strptime(strTmp.c_str(), "%Y:%m:%d %H:%M:%S", &t);
t.tm_isdst = -1;
timestamp = mktime(&t);
file = std::make_pair(*it, timestamp);
vec.push_back(file);
}
else
{
// Error for at least an image in metadata
}
}
}
}
}
else
{
// Error 2: The selected path is not a directory
}
}
else
{
// Error 1: There is no such path
}
return 1;
}
示例5: ReadExif
bool ptImageHelper::ReadExif(const QString &AFileName,
Exiv2::ExifData &AExifData,
std::vector<uint8_t> &AExifBuffer)
{
if (AFileName.trimmed().isEmpty()) return false;
try {
if (Exiv2::ImageFactory::getType(AFileName.toLocal8Bit().data()) == Exiv2::ImageType::none)
return false;
Exiv2::Image::AutoPtr hImage = Exiv2::ImageFactory::open(AFileName.toLocal8Bit().data());
if (!hImage.get()) return false;
hImage->readMetadata();
AExifData = hImage->exifData();
if (AExifData.empty()) {
ptLogWarning(ptWarning_Argument, "No Exif data found in %s", AFileName.toLocal8Bit().data());
return false;
}
Exiv2::ExifData::iterator Pos;
size_t Size;
#if EXIV2_TEST_VERSION(0,17,91) /* Exiv2 0.18-pre1 */
Exiv2::Blob Blob;
Exiv2::ExifParser::encode(Blob, Exiv2::bigEndian, AExifData);
Size = Blob.size();
#else
Exiv2::DataBuf Buf(AExifData.copy());
Size = Buf.size_;
#endif
/* If buffer too big for JPEG, try deleting some stuff. */
if (Size + CExifHeader.size() > CMaxHeaderLength) {
if ((Pos = AExifData.findKey(Exiv2::ExifKey("Exif.Photo.MakerNote"))) != AExifData.end() ) {
AExifData.erase(Pos);
ptLogWarning(ptWarning_Argument, "Exif buffer too big, erasing Exif.Photo.MakerNote");
#if EXIV2_TEST_VERSION(0,17,91) /* Exiv2 0.18-pre1 */
Exiv2::ExifParser::encode(Blob, Exiv2::bigEndian, AExifData);
Size = Blob.size();
#else
Buf = AExifData.copy();
Size = Buf.size_;
#endif
}
}
// Erase embedded thumbnail if needed
if (Settings->GetInt("EraseExifThumbnail") ||
(Size + CExifHeader.size()) > CMaxHeaderLength ) {
#if EXIV2_TEST_VERSION(0,17,91) /* Exiv2 0.18-pre1 */
Exiv2::ExifThumb Thumb(AExifData);
Thumb.erase();
#else
AExifData.eraseThumbnail();
#endif
if (!Settings->GetInt("EraseExifThumbnail"))
ptLogWarning(ptWarning_Argument, "Exif buffer too big, erasing Thumbnail");
#if EXIV2_TEST_VERSION(0,17,91) /* Exiv2 0.18-pre1 */
Exiv2::ExifParser::encode(Blob, Exiv2::bigEndian, AExifData);
Size = Blob.size();
#else
Buf = AExifData.copy();
Size = Buf.size_;
#endif
}
AExifBuffer.clear();
AExifBuffer.insert(AExifBuffer.end(),
CExifHeader.begin(),
CExifHeader.end());
#if EXIV2_TEST_VERSION(0,17,91) /* Exiv2 0.18-pre1 */
AExifBuffer.insert(AExifBuffer.end(),
Blob.begin(),
Blob.end());
#else
// old code will currently not compile
memcpy(AExifBuffer+sizeof(ExifHeader), Buf.pData_, Buf.size_);
#endif
return true;
} catch(Exiv2::Error& Error) {
// Exiv2 errors are in this context hopefully harmless
// (unsupported tags etc.)
ptLogWarning(ptWarning_Exiv2,"Exiv2 : %s\n",Error.what());
}
return false;
}