// Turn one ParamValue (whose xmp info we know) into a properly // serialized xmp string. static std::string stringize(const ParamValueList::const_iterator& p, const XMPtag& xmptag) { if (p->type() == TypeDesc::STRING) { if (xmptag.special & DateConversion) { // FIXME -- convert to yyyy-mm-ddThh:mm:ss.sTZD // return std::string(); } return std::string(*(const char**)p->data()); } else if (p->type() == TypeDesc::INT) { if (xmptag.special & IsBool) return *(const int*)p->data() ? "True" : "False"; else // ordinary int return Strutil::sprintf("%d", *(const int*)p->data()); } else if (p->type() == TypeDesc::FLOAT) { if (xmptag.special & Rational) { unsigned int num, den; float_to_rational(*(const float*)p->data(), num, den); return Strutil::sprintf("%d/%d", num, den); } else { return Strutil::sprintf("%g", *(const float*)p->data()); } } return std::string(); }
void RawInput::read_tiff_metadata (const std::string &filename) { // Many of these raw formats look just like TIFF files, and we can use // that to extract a bunch of extra Exif metadata and thumbnail. ImageInput *in = ImageInput::create ("tiff"); if (! in) { (void) OIIO::geterror(); // eat the error return; } ImageSpec newspec; bool ok = in->open (filename, newspec); if (ok) { // Transfer "Exif:" metadata to the raw spec. for (ParamValueList::const_iterator p = newspec.extra_attribs.begin(); p != newspec.extra_attribs.end(); ++p) { if (Strutil::istarts_with (p->name().c_str(), "Exif:")) { m_spec.attribute (p->name().c_str(), p->type(), p->data()); } } } in->close (); delete in; }