summaryrefslogtreecommitdiff
path: root/src/plugins/exiv2_extractor.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/exiv2_extractor.cc')
-rw-r--r--src/plugins/exiv2_extractor.cc692
1 files changed, 358 insertions, 334 deletions
diff --git a/src/plugins/exiv2_extractor.cc b/src/plugins/exiv2_extractor.cc
index ef402a8..78f9bda 100644
--- a/src/plugins/exiv2_extractor.cc
+++ b/src/plugins/exiv2_extractor.cc
@@ -43,189 +43,194 @@ class ExtractorIO : public Exiv2::BasicIo
{
private:
- /**
- * Extract context we are using.
- */
- struct EXTRACTOR_ExtractContext *ec;
+/**
+ * Extract context we are using.
+ */
+struct EXTRACTOR_ExtractContext *ec;
public:
- /**
- * Constructor.
- *
- * @param s_ec extract context to wrap
- */
- ExtractorIO (struct EXTRACTOR_ExtractContext *s_ec)
- {
- ec = s_ec;
- }
+/**
+ * Constructor.
+ *
+ * @param s_ec extract context to wrap
+ */
+ExtractorIO (struct EXTRACTOR_ExtractContext *s_ec)
+{
+ ec = s_ec;
+}
- /**
- * Destructor.
- */
- virtual ~ExtractorIO ()
- {
- /* nothing to do */
- }
- /**
- * Open stream.
- *
- * @return 0 (always successful)
- */
- virtual int open ();
-
- /**
- * Close stream.
- *
- * @return 0 (always successful)
- */
- virtual int close ();
-
- /**
- * Read up to 'rcount' bytes into a buffer
- *
- * @param rcount number of bytes to read
- * @return buffer with data read, empty buffer (!) on failure (!)
- */
- virtual Exiv2::DataBuf read (long rcount);
-
- /**
- * Read up to 'rcount' bytes into 'buf'.
- *
- * @param buf buffer to fill
- * @param rcount size of 'buf'
- * @return number of bytes read successfully, 0 on failure (!)
- */
- virtual long read (Exiv2::byte *buf,
- long rcount);
-
- /**
- * Read a single character.
- *
- * @return the character
- * @throw exception on errors
- */
- virtual int getb ();
-
- /**
- * Write to stream.
- *
- * @param data data to write
- * @param wcount how many bytes to write
- * @return -1 (always fails)
- */
- virtual long write (const Exiv2::byte *data,
- long wcount);
-
- /**
- * Write to stream.
- *
- * @param src stream to copy
- * @return -1 (always fails)
- */
- virtual long write (Exiv2::BasicIo &src);
-
- /**
- * Write a single byte.
- *
- * @param data byte to write
- * @return -1 (always fails)
- */
- virtual int putb (Exiv2::byte data);
-
- /**
- * Not supported.
- *
- * @throws error
- */
- virtual void transfer (Exiv2::BasicIo& src);
-
- /**
- * Seek to the given offset.
- *
- * @param offset desired offset
- * @parma pos offset is relative to where?
- * @return -1 on failure, 0 on success
- */
- virtual int seek (long offset,
- Exiv2::BasicIo::Position pos);
-
- /**
- * Not supported.
- *
- * @throws error
- */
- virtual Exiv2::byte* mmap (bool isWritable);
-
- /**
- * Not supported.
- *
- * @return -1 (error)
- */
- virtual int munmap ();
-
- /**
- * Return our current offset in the file.
- *
- * @return -1 on error
- */
- virtual long int tell (void) const;
-
- /**
- * Return overall size of the file.
- *
- * @return -1 on error
- */
-#if EXIV2_TEST_VERSION(0,26,0)
- virtual size_t size (void) const;
+/**
+ * Destructor.
+ */
+virtual ~ExtractorIO ()
+{
+ /* nothing to do */
+}
+
+
+/**
+ * Open stream.
+ *
+ * @return 0 (always successful)
+ */
+virtual int open ();
+
+/**
+ * Close stream.
+ *
+ * @return 0 (always successful)
+ */
+virtual int close ();
+
+/**
+ * Read up to 'rcount' bytes into a buffer
+ *
+ * @param rcount number of bytes to read
+ * @return buffer with data read, empty buffer (!) on failure (!)
+ */
+virtual Exiv2::DataBuf read (long rcount);
+
+/**
+ * Read up to 'rcount' bytes into 'buf'.
+ *
+ * @param buf buffer to fill
+ * @param rcount size of 'buf'
+ * @return number of bytes read successfully, 0 on failure (!)
+ */
+virtual long read (Exiv2::byte *buf,
+ long rcount);
+
+/**
+ * Read a single character.
+ *
+ * @return the character
+ * @throw exception on errors
+ */
+virtual int getb ();
+
+/**
+ * Write to stream.
+ *
+ * @param data data to write
+ * @param wcount how many bytes to write
+ * @return -1 (always fails)
+ */
+virtual long write (const Exiv2::byte *data,
+ long wcount);
+
+/**
+ * Write to stream.
+ *
+ * @param src stream to copy
+ * @return -1 (always fails)
+ */
+virtual long write (Exiv2::BasicIo &src);
+
+/**
+ * Write a single byte.
+ *
+ * @param data byte to write
+ * @return -1 (always fails)
+ */
+virtual int putb (Exiv2::byte data);
+
+/**
+ * Not supported.
+ *
+ * @throws error
+ */
+virtual void transfer (Exiv2::BasicIo& src);
+
+/**
+ * Seek to the given offset.
+ *
+ * @param offset desired offset
+ * @parma pos offset is relative to where?
+ * @return -1 on failure, 0 on success
+ */
+virtual int seek (long offset,
+ Exiv2::BasicIo::Position pos);
+
+/**
+ * Not supported.
+ *
+ * @throws error
+ */
+virtual Exiv2::byte*mmap (bool isWritable);
+
+/**
+ * Not supported.
+ *
+ * @return -1 (error)
+ */
+virtual int munmap ();
+
+/**
+ * Return our current offset in the file.
+ *
+ * @return -1 on error
+ */
+virtual long int tell (void) const;
+
+/**
+ * Return overall size of the file.
+ *
+ * @return -1 on error
+ */
+#if EXIV2_TEST_VERSION (0,26,0)
+virtual size_t size (void) const;
+
#else
- virtual long int size (void) const;
+virtual long int size (void) const;
+
#endif
- /**
- * Check if file is open.
- *
- * @return true (always).
- */
- virtual bool isopen () const;
-
- /**
- * Check if this file source is in error mode.
- *
- * @return 0 (always all is fine).
- */
- virtual int error () const;
-
- /**
- * Check if current position of the file is at the end
- *
- * @return true if at EOF, false if not.
- */
- virtual bool eof () const;
-
- /**
- * Not supported.
- *
- * @throws error
- */
- virtual std::string path () const;
+/**
+ * Check if file is open.
+ *
+ * @return true (always).
+ */
+virtual bool isopen () const;
+
+/**
+ * Check if this file source is in error mode.
+ *
+ * @return 0 (always all is fine).
+ */
+virtual int error () const;
+
+/**
+ * Check if current position of the file is at the end
+ *
+ * @return true if at EOF, false if not.
+ */
+virtual bool eof () const;
+
+/**
+ * Not supported.
+ *
+ * @throws error
+ */
+virtual std::string path () const;
#ifdef EXV_UNICODE_PATH
- /**
- * Not supported.
- *
- * @throws error
- */
- virtual std::wstring wpath () const;
+/**
+ * Not supported.
+ *
+ * @throws error
+ */
+virtual std::wstring wpath () const;
+
#endif
- /**
- * Not supported.
- *
- * @throws error
- */
- virtual Exiv2::BasicIo::AutoPtr temporary () const;
+/**
+ * Not supported.
+ *
+ * @throws error
+ */
+virtual Exiv2::BasicIo::AutoPtr temporary () const;
};
@@ -241,6 +246,7 @@ ExtractorIO::open ()
return 0;
}
+
/**
* Close stream.
*
@@ -280,7 +286,7 @@ ExtractorIO::read (long rcount)
*/
long
ExtractorIO::read (Exiv2::byte *buf,
- long rcount)
+ long rcount)
{
void *data;
ssize_t ret;
@@ -288,14 +294,14 @@ ExtractorIO::read (Exiv2::byte *buf,
got = 0;
while (got < rcount)
- {
- if (-1 == (ret = ec->read (ec->cls, &data, rcount - got)))
- return got;
- if (0 == ret)
- break;
- memcpy (&buf[got], data, ret);
- got += ret;
- }
+ {
+ if (-1 == (ret = ec->read (ec->cls, &data, rcount - got)))
+ return got;
+ if (0 == ret)
+ break;
+ memcpy (&buf[got], data, ret);
+ got += ret;
+ }
return got;
}
@@ -313,7 +319,7 @@ ExtractorIO::getb ()
const unsigned char *r;
if (1 != ec->read (ec->cls, &data, 1))
-#if EXIV2_TEST_VERSION(0,27,0)
+#if EXIV2_TEST_VERSION (0,27,0)
throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
#else
throw Exiv2::BasicError<char> (42 /* error code */);
@@ -332,7 +338,7 @@ ExtractorIO::getb ()
*/
long
ExtractorIO::write (const Exiv2::byte *data,
- long wcount)
+ long wcount)
{
return -1;
}
@@ -372,8 +378,8 @@ ExtractorIO::putb (Exiv2::byte data)
void
ExtractorIO::transfer (Exiv2::BasicIo& src)
{
-#if EXIV2_TEST_VERSION(0,27,0)
- throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
+#if EXIV2_TEST_VERSION (0,27,0)
+ throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
#else
throw Exiv2::BasicError<char> (42 /* error code */);
#endif
@@ -389,24 +395,24 @@ ExtractorIO::transfer (Exiv2::BasicIo& src)
*/
int
ExtractorIO::seek (long offset,
- Exiv2::BasicIo::Position pos)
+ Exiv2::BasicIo::Position pos)
{
int rel;
switch (pos)
- {
- case beg: // Exiv2::BasicIo::beg:
- rel = SEEK_SET;
- break;
- case cur:
- rel = SEEK_CUR;
- break;
- case end:
- rel = SEEK_END;
- break;
- default:
- abort ();
- }
+ {
+ case beg: // Exiv2::BasicIo::beg:
+ rel = SEEK_SET;
+ break;
+ case cur:
+ rel = SEEK_CUR;
+ break;
+ case end:
+ rel = SEEK_END;
+ break;
+ default:
+ abort ();
+ }
if (-1 == ec->seek (ec->cls, offset, rel))
return -1;
return 0;
@@ -421,8 +427,8 @@ ExtractorIO::seek (long offset,
Exiv2::byte *
ExtractorIO::mmap (bool isWritable)
{
-#if EXIV2_TEST_VERSION(0,27,0)
- throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
+#if EXIV2_TEST_VERSION (0,27,0)
+ throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
#else
throw Exiv2::BasicError<char> (42 /* error code */);
#endif
@@ -458,7 +464,7 @@ ExtractorIO::tell (void) const
*
* @return -1 on error
*/
-#if EXIV2_TEST_VERSION(0,26,0)
+#if EXIV2_TEST_VERSION (0,26,0)
size_t
#else
long int
@@ -513,8 +519,8 @@ ExtractorIO::eof () const
std::string
ExtractorIO::path () const
{
-#if EXIV2_TEST_VERSION(0,27,0)
- throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
+#if EXIV2_TEST_VERSION (0,27,0)
+ throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
#else
throw Exiv2::BasicError<char> (42 /* error code */);
#endif
@@ -530,12 +536,14 @@ ExtractorIO::path () const
std::wstring
ExtractorIO::wpath () const
{
-#if EXIV2_TEST_VERSION(0,27,0)
- throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
+#if EXIV2_TEST_VERSION (0,27,0)
+ throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
#else
throw Exiv2::BasicError<char> (42 /* error code */);
#endif
}
+
+
#endif
@@ -548,8 +556,8 @@ Exiv2::BasicIo::AutoPtr
ExtractorIO::temporary () const
{
fprintf (stderr, "throwing temporary error\n");
-#if EXIV2_TEST_VERSION(0,27,0)
- throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
+#if EXIV2_TEST_VERSION (0,27,0)
+ throw Exiv2::BasicError<char> (Exiv2::kerDecodeLangAltQualifierFailed);
#else
throw Exiv2::BasicError<char> (42 /* error code */);
#endif
@@ -563,7 +571,11 @@ ExtractorIO::temporary () const
* @param s 0-terminated UTF8 string value with the meta data
* @param type libextractor type for the meta data
*/
-#define ADD(s, type) do { if (0 != proc (proc_cls, "exiv2", type, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return 1; } while (0)
+#define ADD(s, type) do { if (0 != proc (proc_cls, "exiv2", type, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1)) return 1; \
+} while (0)
/**
@@ -579,10 +591,10 @@ ExtractorIO::temporary () const
*/
static int
add_exiv2_tag (const Exiv2::ExifData& exifData,
- const std::string& key,
- enum EXTRACTOR_MetaType type,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ const std::string& key,
+ enum EXTRACTOR_MetaType type,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
const char *str;
Exiv2::ExifKey ek (key);
@@ -590,8 +602,8 @@ add_exiv2_tag (const Exiv2::ExifData& exifData,
if (exifData.end () == md)
return 0; /* not found */
- std::string ccstr = Exiv2::toString(*md);
- str = ccstr.c_str();
+ std::string ccstr = Exiv2::toString (*md);
+ str = ccstr.c_str ();
/* skip over whitespace */
while ( (strlen (str) > 0) && isspace ((unsigned char) str[0]))
str++;
@@ -615,28 +627,28 @@ add_exiv2_tag (const Exiv2::ExifData& exifData,
*/
static int
add_iptc_data (const Exiv2::IptcData& iptcData,
- const std::string& key,
- enum EXTRACTOR_MetaType type,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ const std::string& key,
+ enum EXTRACTOR_MetaType type,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
const char *str;
Exiv2::IptcKey ek (key);
Exiv2::IptcData::const_iterator md = iptcData.findKey (ek);
while (iptcData.end () != md)
- {
- if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ()))
- break;
- std::string ccstr = Exiv2::toString (*md);
- str = ccstr.c_str ();
- /* skip over whitespace */
- while ((strlen (str) > 0) && isspace ((unsigned char) str[0]))
- str++;
- if (strlen (str) > 0)
- ADD (str, type);
- md++;
- }
+ {
+ if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ()))
+ break;
+ std::string ccstr = Exiv2::toString (*md);
+ str = ccstr.c_str ();
+ /* skip over whitespace */
+ while ((strlen (str) > 0) && isspace ((unsigned char) str[0]))
+ str++;
+ if (strlen (str) > 0)
+ ADD (str, type);
+ md++;
+ }
return 0;
}
@@ -654,26 +666,27 @@ add_iptc_data (const Exiv2::IptcData& iptcData,
*/
static int
add_xmp_data (const Exiv2::XmpData& xmpData,
- const std::string& key,
- enum EXTRACTOR_MetaType type,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ const std::string& key,
+ enum EXTRACTOR_MetaType type,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
- const char * str;
+ const char *str;
Exiv2::XmpKey ek (key);
Exiv2::XmpData::const_iterator md = xmpData.findKey (ek);
while (xmpData.end () != md)
- {
- if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ()))
- break;
- std::string ccstr = Exiv2::toString (*md);
- str = ccstr.c_str ();
- while ( (strlen (str) > 0) && isspace ((unsigned char) str[0])) str++;
- if (strlen (str) > 0)
- ADD (str, type);
- md++;
- }
+ {
+ if (0 != strcmp (Exiv2::toString (md->key ()).c_str (), key.c_str ()))
+ break;
+ std::string ccstr = Exiv2::toString (*md);
+ str = ccstr.c_str ();
+ while ( (strlen (str) > 0) && isspace ((unsigned char) str[0]))
+ str++;
+ if (strlen (str) > 0)
+ ADD (str, type);
+ md++;
+ }
return 0;
}
@@ -685,7 +698,8 @@ add_xmp_data (const Exiv2::XmpData& xmpData,
* @param s key to lookup
* @param type libextractor type to use for the meta data found under the given key
*/
-#define ADDEXIV(s,t) do { if (0 != add_exiv2_tag (exifData, s, t, ec->proc, ec->cls)) return; } while (0)
+#define ADDEXIV(s,t) do { if (0 != add_exiv2_tag (exifData, s, t, ec->proc, \
+ ec->cls)) return; } while (0)
/**
@@ -695,7 +709,8 @@ add_xmp_data (const Exiv2::XmpData& xmpData,
* @param s key to lookup
* @param type libextractor type to use for the meta data found under the given key
*/
-#define ADDIPTC(s,t) do { if (0 != add_iptc_data (iptcData, s, t, ec->proc, ec->cls)) return; } while (0)
+#define ADDIPTC(s,t) do { if (0 != add_iptc_data (iptcData, s, t, ec->proc, \
+ ec->cls)) return; } while (0)
/**
@@ -705,7 +720,8 @@ add_xmp_data (const Exiv2::XmpData& xmpData,
* @param s key to lookup
* @param type libextractor type to use for the meta data found under the given key
*/
-#define ADDXMP(s,t) do { if (0 != add_xmp_data (xmpData, s, t, ec->proc, ec->cls)) return; } while (0)
+#define ADDXMP(s,t) do { if (0 != add_xmp_data (xmpData, s, t, ec->proc, \
+ ec->cls)) return; } while (0)
/**
@@ -717,97 +733,105 @@ extern "C" void
EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec)
{
try
- {
-#if !EXIV2_TEST_VERSION(0,24,0)
- Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute);
+ {
+#if ! EXIV2_TEST_VERSION (0,24,0)
+ Exiv2::LogMsg::setLevel (Exiv2::LogMsg::mute);
#endif
- std::auto_ptr<Exiv2::BasicIo> eio(new ExtractorIO (ec));
- Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (eio);
- if (0 == image.get ())
- return;
- image->readMetadata ();
- Exiv2::ExifData &exifData = image->exifData ();
- if (! exifData.empty ())
- {
- ADDEXIV ("Exif.Image.Copyright", EXTRACTOR_METATYPE_COPYRIGHT);
- ADDEXIV ("Exif.Photo.UserComment", EXTRACTOR_METATYPE_COMMENT);
- ADDEXIV ("Exif.GPSInfo.GPSLatitudeRef", EXTRACTOR_METATYPE_GPS_LATITUDE_REF);
- ADDEXIV ("Exif.GPSInfo.GPSLatitude", EXTRACTOR_METATYPE_GPS_LATITUDE);
- ADDEXIV ("Exif.GPSInfo.GPSLongitudeRef", EXTRACTOR_METATYPE_GPS_LONGITUDE_REF);
- ADDEXIV ("Exif.GPSInfo.GPSLongitude", EXTRACTOR_METATYPE_GPS_LONGITUDE);
- ADDEXIV ("Exif.Image.Make", EXTRACTOR_METATYPE_CAMERA_MAKE);
- ADDEXIV ("Exif.Image.Model", EXTRACTOR_METATYPE_CAMERA_MODEL);
- ADDEXIV ("Exif.Image.Orientation", EXTRACTOR_METATYPE_ORIENTATION);
- ADDEXIV ("Exif.Photo.DateTimeOriginal", EXTRACTOR_METATYPE_CREATION_DATE);
- ADDEXIV ("Exif.Photo.ExposureBiasValue", EXTRACTOR_METATYPE_EXPOSURE_BIAS);
- ADDEXIV ("Exif.Photo.Flash", EXTRACTOR_METATYPE_FLASH);
- ADDEXIV ("Exif.CanonSi.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
- ADDEXIV ("Exif.Panasonic.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
- ADDEXIV ("Exif.Olympus.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
- ADDEXIV ("Exif.Photo.FocalLength", EXTRACTOR_METATYPE_FOCAL_LENGTH);
- ADDEXIV ("Exif.Photo.FocalLengthIn35mmFilm", EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM);
- ADDEXIV ("Exif.Photo.ISOSpeedRatings", EXTRACTOR_METATYPE_ISO_SPEED);
- ADDEXIV ("Exif.CanonSi.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
- ADDEXIV ("Exif.Nikon1.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
- ADDEXIV ("Exif.Nikon2.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
- ADDEXIV ("Exif.Nikon3.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
- ADDEXIV ("Exif.Photo.ExposureProgram", EXTRACTOR_METATYPE_EXPOSURE_MODE);
- ADDEXIV ("Exif.CanonCs.ExposureProgram", EXTRACTOR_METATYPE_EXPOSURE_MODE);
- ADDEXIV ("Exif.Photo.MeteringMode", EXTRACTOR_METATYPE_METERING_MODE);
- ADDEXIV ("Exif.CanonCs.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
- ADDEXIV ("Exif.Fujifilm.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
- ADDEXIV ("Exif.Olympus.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
- ADDEXIV ("Exif.Panasonic.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
- ADDEXIV ("Exif.CanonCs.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
- ADDEXIV ("Exif.Fujifilm.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
- ADDEXIV ("Exif.Sigma.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
- ADDEXIV ("Exif.Nikon1.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
- ADDEXIV ("Exif.Nikon2.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
- ADDEXIV ("Exif.Nikon3.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
- ADDEXIV ("Exif.Olympus.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
- ADDEXIV ("Exif.Panasonic.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
- ADDEXIV ("Exif.CanonSi.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
- ADDEXIV ("Exif.Fujifilm.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
- ADDEXIV ("Exif.Sigma.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
- ADDEXIV ("Exif.Nikon1.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
- ADDEXIV ("Exif.Nikon2.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
- ADDEXIV ("Exif.Nikon3.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
- ADDEXIV ("Exif.Olympus.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
- ADDEXIV ("Exif.Panasonic.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
- ADDEXIV ("Exif.Photo.FNumber", EXTRACTOR_METATYPE_APERTURE);
- ADDEXIV ("Exif.Photo.ExposureTime", EXTRACTOR_METATYPE_EXPOSURE);
- }
-
- Exiv2::IptcData &iptcData = image->iptcData();
- if (! iptcData.empty())
- {
- ADDIPTC ("Iptc.Application2.Keywords", EXTRACTOR_METATYPE_KEYWORDS);
- ADDIPTC ("Iptc.Application2.City", EXTRACTOR_METATYPE_LOCATION_CITY);
- ADDIPTC ("Iptc.Application2.SubLocation", EXTRACTOR_METATYPE_LOCATION_SUBLOCATION);
- ADDIPTC ("Iptc.Application2.CountryName", EXTRACTOR_METATYPE_LOCATION_COUNTRY);
- }
-
- Exiv2::XmpData &xmpData = image->xmpData();
- if (! xmpData.empty())
- {
- ADDXMP ("Xmp.photoshop.Country", EXTRACTOR_METATYPE_LOCATION_COUNTRY);
- ADDXMP ("Xmp.photoshop.City", EXTRACTOR_METATYPE_LOCATION_CITY);
- ADDXMP ("Xmp.xmp.Rating", EXTRACTOR_METATYPE_RATING);
- ADDXMP ("Xmp.MicrosoftPhoto.Rating", EXTRACTOR_METATYPE_RATING);
- ADDXMP ("Xmp.iptc.CountryCode", EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE);
- ADDXMP ("Xmp.xmp.CreatorTool", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);
- ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT);
- }
- }
- catch (const Exiv2::AnyError& e)
+ std::auto_ptr<Exiv2::BasicIo> eio (new ExtractorIO (ec));
+ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open (eio);
+ if (0 == image.get ())
+ return;
+ image->readMetadata ();
+ Exiv2::ExifData &exifData = image->exifData ();
+ if (! exifData.empty ())
{
-#if DEBUG
- std::cerr << "Caught Exiv2 exception '" << e << "'\n";
-#endif
+ ADDEXIV ("Exif.Image.Copyright", EXTRACTOR_METATYPE_COPYRIGHT);
+ ADDEXIV ("Exif.Photo.UserComment", EXTRACTOR_METATYPE_COMMENT);
+ ADDEXIV ("Exif.GPSInfo.GPSLatitudeRef",
+ EXTRACTOR_METATYPE_GPS_LATITUDE_REF);
+ ADDEXIV ("Exif.GPSInfo.GPSLatitude", EXTRACTOR_METATYPE_GPS_LATITUDE);
+ ADDEXIV ("Exif.GPSInfo.GPSLongitudeRef",
+ EXTRACTOR_METATYPE_GPS_LONGITUDE_REF);
+ ADDEXIV ("Exif.GPSInfo.GPSLongitude", EXTRACTOR_METATYPE_GPS_LONGITUDE);
+ ADDEXIV ("Exif.Image.Make", EXTRACTOR_METATYPE_CAMERA_MAKE);
+ ADDEXIV ("Exif.Image.Model", EXTRACTOR_METATYPE_CAMERA_MODEL);
+ ADDEXIV ("Exif.Image.Orientation", EXTRACTOR_METATYPE_ORIENTATION);
+ ADDEXIV ("Exif.Photo.DateTimeOriginal", EXTRACTOR_METATYPE_CREATION_DATE);
+ ADDEXIV ("Exif.Photo.ExposureBiasValue",
+ EXTRACTOR_METATYPE_EXPOSURE_BIAS);
+ ADDEXIV ("Exif.Photo.Flash", EXTRACTOR_METATYPE_FLASH);
+ ADDEXIV ("Exif.CanonSi.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
+ ADDEXIV ("Exif.Panasonic.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
+ ADDEXIV ("Exif.Olympus.FlashBias", EXTRACTOR_METATYPE_FLASH_BIAS);
+ ADDEXIV ("Exif.Photo.FocalLength", EXTRACTOR_METATYPE_FOCAL_LENGTH);
+ ADDEXIV ("Exif.Photo.FocalLengthIn35mmFilm",
+ EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM);
+ ADDEXIV ("Exif.Photo.ISOSpeedRatings", EXTRACTOR_METATYPE_ISO_SPEED);
+ ADDEXIV ("Exif.CanonSi.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
+ ADDEXIV ("Exif.Nikon1.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
+ ADDEXIV ("Exif.Nikon2.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
+ ADDEXIV ("Exif.Nikon3.ISOSpeed", EXTRACTOR_METATYPE_ISO_SPEED);
+ ADDEXIV ("Exif.Photo.ExposureProgram", EXTRACTOR_METATYPE_EXPOSURE_MODE);
+ ADDEXIV ("Exif.CanonCs.ExposureProgram",
+ EXTRACTOR_METATYPE_EXPOSURE_MODE);
+ ADDEXIV ("Exif.Photo.MeteringMode", EXTRACTOR_METATYPE_METERING_MODE);
+ ADDEXIV ("Exif.CanonCs.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
+ ADDEXIV ("Exif.Fujifilm.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
+ ADDEXIV ("Exif.Olympus.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
+ ADDEXIV ("Exif.Panasonic.Macro", EXTRACTOR_METATYPE_MACRO_MODE);
+ ADDEXIV ("Exif.CanonCs.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
+ ADDEXIV ("Exif.Fujifilm.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
+ ADDEXIV ("Exif.Sigma.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
+ ADDEXIV ("Exif.Nikon1.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
+ ADDEXIV ("Exif.Nikon2.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
+ ADDEXIV ("Exif.Nikon3.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
+ ADDEXIV ("Exif.Olympus.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
+ ADDEXIV ("Exif.Panasonic.Quality", EXTRACTOR_METATYPE_IMAGE_QUALITY);
+ ADDEXIV ("Exif.CanonSi.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
+ ADDEXIV ("Exif.Fujifilm.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
+ ADDEXIV ("Exif.Sigma.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
+ ADDEXIV ("Exif.Nikon1.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
+ ADDEXIV ("Exif.Nikon2.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
+ ADDEXIV ("Exif.Nikon3.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
+ ADDEXIV ("Exif.Olympus.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
+ ADDEXIV ("Exif.Panasonic.WhiteBalance", EXTRACTOR_METATYPE_WHITE_BALANCE);
+ ADDEXIV ("Exif.Photo.FNumber", EXTRACTOR_METATYPE_APERTURE);
+ ADDEXIV ("Exif.Photo.ExposureTime", EXTRACTOR_METATYPE_EXPOSURE);
}
- catch (void *anything)
+
+ Exiv2::IptcData &iptcData = image->iptcData ();
+ if (! iptcData.empty ())
+ {
+ ADDIPTC ("Iptc.Application2.Keywords", EXTRACTOR_METATYPE_KEYWORDS);
+ ADDIPTC ("Iptc.Application2.City", EXTRACTOR_METATYPE_LOCATION_CITY);
+ ADDIPTC ("Iptc.Application2.SubLocation",
+ EXTRACTOR_METATYPE_LOCATION_SUBLOCATION);
+ ADDIPTC ("Iptc.Application2.CountryName",
+ EXTRACTOR_METATYPE_LOCATION_COUNTRY);
+ }
+
+ Exiv2::XmpData &xmpData = image->xmpData ();
+ if (! xmpData.empty ())
{
+ ADDXMP ("Xmp.photoshop.Country", EXTRACTOR_METATYPE_LOCATION_COUNTRY);
+ ADDXMP ("Xmp.photoshop.City", EXTRACTOR_METATYPE_LOCATION_CITY);
+ ADDXMP ("Xmp.xmp.Rating", EXTRACTOR_METATYPE_RATING);
+ ADDXMP ("Xmp.MicrosoftPhoto.Rating", EXTRACTOR_METATYPE_RATING);
+ ADDXMP ("Xmp.iptc.CountryCode", EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE);
+ ADDXMP ("Xmp.xmp.CreatorTool", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);
+ ADDXMP ("Xmp.lr.hierarchicalSubject", EXTRACTOR_METATYPE_SUBJECT);
}
+ }
+ catch (const Exiv2::AnyError& e)
+ {
+#if DEBUG
+ std::cerr << "Caught Exiv2 exception '" << e << "'\n";
+#endif
+ }
+ catch (void *anything)
+ {
+ }
}
+
/* end of exiv2_extractor.cc */