Ejemplo n.º 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());
}