Пример #1
0
void NegativeProcessor::setXmpFromRaw(const dng_date_time_info &dateTimeNow, const dng_string &appNameVersion) {
    // -----------------------------------------------------------------------------------------
    // Copy existing XMP-tags in raw-file to DNG

    AutoPtr<dng_xmp> negXmp(new dng_xmp(m_host->Allocator()));
    for (Exiv2::XmpData::const_iterator it = m_RawXmp.begin(); it != m_RawXmp.end(); it++) {
        try {
            negXmp->Set(Exiv2::XmpProperties::nsInfo(it->groupName())->ns_, it->tagName().c_str(), it->toString().c_str());
        }
        catch (dng_exception& e) {
            // the above will throw an exception when trying to add XMPs with unregistered (i.e., unknown) 
            // namespaces -- we just drop them here.
            std::cerr << "Dropped XMP-entry from raw-file since namespace is unknown: "
                         "NS: "   << Exiv2::XmpProperties::nsInfo(it->groupName())->ns_ << ", "
                         "path: " << it->tagName().c_str() << ", "
                         "text: " << it->toString().c_str() << "\n";
        }
    }

    // -----------------------------------------------------------------------------------------
    // Set some base-XMP tags (incl. redundant creation date under Photoshop namespace - just to stay close to Adobe...)

    negXmp->UpdateDateTime(dateTimeNow);
    negXmp->UpdateMetadataDate(dateTimeNow);
    negXmp->SetString(XMP_NS_XAP, "CreatorTool", appNameVersion);
    negXmp->Set(XMP_NS_DC, "format", "image/dng");
    negXmp->SetString(XMP_NS_PHOTOSHOP, "DateCreated", m_negative->GetExif()->fDateTimeOriginal.Encode_ISO_8601());

    m_negative->ResetXMP(negXmp.Release());
}
Пример #2
0
JSONNODE *ImgTagJson::genLitXmp(const Exiv2::Image::AutoPtr & image)
{
    Exiv2::XmpData &data = image->xmpData();
    data.sortByKey();

    if (data.empty()) return NULL;

    Exiv2::XmpData::const_iterator end = data.end();

    JMAP *grpmap = new JMAP();
    JSONNODE *tree = json_new(JSON_NODE);
    for (Exiv2::XmpData::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::XmpData::const_iterator nxt = i + 1;
        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;
            i = nxt - 1;
        }
        else
        {
            json_push_back(grp, json_new_a((i->tagName()).c_str(),
                (i->print()).c_str()));
        }
        //cout << json_write_formatted(grp) << endl;
    }
    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;
    json_set_name(tree, "xmp");
    return tree;
}