Hello I'm trying to read metadata from image using exiv2, but when opening the file I get the following error: Microsoft C++ exception: std::bad_alloc
I'm using default c++ visual studio 2019 compiler.
#include <iostream>
#include "exiv2/exiv2.hpp"
inline bool file_exists(const std::string& name) {
struct stat buffer;
return (stat(name.c_str(), &buffer) == 0);
}
int main(void)
{
try
{
Exiv2::XmpParser::initialize();
::atexit(Exiv2::XmpParser::terminate);
#ifdef EXV_ENABLE_BMFF
Exiv2::enableBMFF();
#endif
const char* file = "E:/img/DJI_0001.jpg";
if (!file_exists(file)) return 0;
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
assert(image.get() != 0);
image->readMetadata();
}
catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e.what() << "'\n";
return -1;
}