0

I'm using Exiv2 to take the metadata of photograph. I would like to use some value of these metadata. but I have no idea how to convert exiv2 value to int. here is my souse cord.

int metadetascanner(const char* img)
{
    try
    {
        Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(img);
        image->readMetadata();
        Exiv2::ExifData &exif = image->exifData();
        Exiv2::Exifdatum &rotation = exif["Exif.Image.Orientation"];

        if (exif.empty())
        {
            cerr << "no exif" << endl;
            return -1;
            }

        int a = rotation.value();

        return a;
    }

    catch (Exiv2::Error& e)
    {
        cout << e.what() << endl;
        return -1;
    }
}

I just write "int a = rotation.value(); " but I know it can not be like this.

I will really appreciate you if you help me.

1 Answers1

0

From the Exiv2 documentation, the orientation tag is already a short, so your "int a = rotation.value();" idea is valid.

Edited: From API documentation of ExifDatum

int a = rotation.toLong();

The return value meaning you read here.

Please comment if there is any thing wrong. I have not use Exiv2 for years.

khôi nguyễn
  • 626
  • 6
  • 15
  • thank you for your reply. value means that it can give us values of metadata. in case of my program, I want to get an orientation value. this is the error cord "error: cannot convert ‘const Exiv2::Value’ to ‘int’ in initialization" – yuta motomura Nov 16 '16 at 08:07
  • I will try at home and give you my trial. @yutamotomura – khôi nguyễn Nov 16 '16 at 10:36