aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/exiv2_extractor.cc
blob: ff901020debba9e2ee0416cfaf9a83e1a2b40cf2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
// ***************************************************************** -*- C++ -*-
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
 */
/**
 * @file plugins/exiv2_extractor.cc
 * @brief libextractor plugin for Exif using exiv2
 * @author Andreas Huggel (ahu)
 * @author Christian Grothoff
 */
#include "platform.h"
#include "extractor.h"
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <math.h>
#include <exiv2/exif.hpp>
#include <exiv2/error.hpp>
#include <exiv2/image.hpp>
#include <exiv2/futils.hpp>

/**
 * Enable debugging to get error messages.
 */
#define DEBUG 0


/**
 * Implementation of EXIV2's BasicIO interface based
 * on the 'struct EXTRACTOR_ExtractContext.
 */
class ExtractorIO : public Exiv2::BasicIo
{
private:

  /**
   * 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;
  }

  /**
   * 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
   */
  virtual long int size (void) 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;
#endif
  
  /**
   * Not supported.
   *
   * @throws error
   */
  virtual Exiv2::BasicIo::AutoPtr temporary () const;

};
  

/**
 * Open stream.
 * 
 * @return 0 (always successful)
 */
int 
ExtractorIO::open ()
{
  return 0;
}

/**
 * Close stream.
 * 
 * @return 0 (always successful)
 */
int 
ExtractorIO::close ()
{
  return 0;
}


/**
 * Read up to 'rcount' bytes into a buffer
 *
 * @param rcount number of bytes to read
 * @return buffer with data read, empty buffer (!) on failure (!)
 */
Exiv2::DataBuf
ExtractorIO::read (long rcount)
{
  void *data;
  ssize_t ret;

  if (-1 == (ret = ec->read (ec->cls, &data, rcount)))
    return Exiv2::DataBuf (NULL, 0);
  return Exiv2::DataBuf ((const Exiv2::byte *) data, ret);
}


/**
 * 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 (!)
 */
long 
ExtractorIO::read (Exiv2::byte *buf,
		   long rcount)
{
  void *data;
  ssize_t ret;
  long got;

  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;
    }
  return got;
}


/**
 * Read a single character.
 *
 * @return the character
 * @throw exception on errors
 */
int 
ExtractorIO::getb ()
{
  void *data;
  const unsigned char *r;
  
  if (1 != ec->read (ec->cls, &data, 1))
    throw Exiv2::BasicError<char> (42 /* error code */);
  r = (const unsigned char *) data;
  return *r;
}


/**
 * Write to stream.
 *
 * @param data data to write
 * @param wcount how many bytes to write
 * @return -1 (always fails)
 */ 
long 
ExtractorIO::write (const Exiv2::byte *data,
		    long wcount)
{
  return -1;
}


/**
 * Write to stream.
 *
 * @param src stream to copy
 * @return -1 (always fails)
 */ 
long 
ExtractorIO::write (Exiv2::BasicIo &src)
{
  return -1;
}


/**
 * Write a single byte.
 *
 * @param data byte to write
 * @return -1 (always fails)
 */
int 
ExtractorIO::putb (Exiv2::byte data)
{
  return -1;
}


/**
 * Not supported.
 *
 * @throws error
 */
void
ExtractorIO::transfer (Exiv2::BasicIo& src)
{
  throw Exiv2::BasicError<char> (42 /* error code */);
}


/**
 * Seek to the given offset.
 *
 * @param offset desired offset
 * @parma pos offset is relative to where?
 * @return -1 on failure, 0 on success
 */
int 
ExtractorIO::seek (long offset,
		   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 ();
    }
  if (-1 == ec->seek (ec->cls, offset, rel))
    return -1;
  return 0;
}


/**
 * Not supported.
 *
 * @throws error
 */
Exiv2::byte *
ExtractorIO::mmap (bool isWritable)
{
  throw Exiv2::BasicError<char> (42 /* error code */);
}


/**
 * Not supported.
 *
 * @return -1 error
 */
int
ExtractorIO::munmap ()
{
  return -1;
}


/**
 * Return our current offset in the file.
 *
 * @return -1 on error
 */
long int
ExtractorIO::tell (void) const
{
  return (long) ec->seek (ec->cls, 0, SEEK_CUR);
}


/**
 * Return overall size of the file.
 *
 * @return -1 on error
 */
long int 
ExtractorIO::size (void) const
{
  return (long) ec->get_size (ec->cls);
}


/**
 * Check if file is open.
 * 
 * @return true (always).
 */
bool 
ExtractorIO::isopen () const
{
  return true;
}


/**
 * Check if this file source is in error mode.
 *
 * @return 0 (always all is fine).
 */
int
ExtractorIO::error () const
{
  return 0;
}


/**
 * Check if current position of the file is at the end
 * 
 * @return true if at EOF, false if not.
 */
bool 
ExtractorIO::eof () const
{
  return size () == tell ();
}


/**
 * Not supported.
 *
 * @throws error
 */
std::string
ExtractorIO::path () const
{
  throw Exiv2::BasicError<char> (42 /* error code */);
}


#ifdef EXV_UNICODE_PATH
/**
 * Not supported.
 *
 * @throws error
 */
std::wstring
ExtractorIO::wpath () const
{
  throw Exiv2::BasicError<char> (42 /* error code */);
}
#endif


/**
 * Not supported.
 *
 * @throws error
 */
Exiv2::BasicIo::AutoPtr
ExtractorIO::temporary () const
{
  fprintf (stderr, "throwing temporary error\n");
  throw Exiv2::BasicError<char> (42 /* error code */);
}


/**
 * Pass the given UTF-8 string to the 'proc' callback using
 * the given type.  Uses 'return 1' if 'proc' returns non-0.
 *
 * @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)


/**
 * Try to find a given key in the exifData and if a value is
 * found, pass it to 'proc'.
 *
 * @param exifData metadata set to inspect
 * @param key key to lookup in exifData
 * @param type extractor type to use
 * @param proc function to call with results
 * @param proc_cls closurer for proc
 * @return 0 to continue extracting, 1 to abort
 */
static int
add_exiv2_tag (const Exiv2::ExifData& exifData,
	       const std::string& key,
	       enum EXTRACTOR_MetaType type,
	       EXTRACTOR_MetaDataProcessor proc,
	       void *proc_cls)
{
  const char *str;
  Exiv2::ExifKey ek (key);
  Exiv2::ExifData::const_iterator md = exifData.findKey (ek);

  if (exifData.end () == md) 
    return 0; /* not found */
  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;
}


/**
 * Try to find a given key in the iptcData and if a value is
 * found, pass it to 'proc'.
 *
 * @param ipctData metadata set to inspect
 * @param key key to lookup in exifData
 * @param type extractor type to use
 * @param proc function to call with results
 * @param proc_cls closurer for proc
 * @return 0 to continue extracting, 1 to abort
 */
static int
add_iptc_data (const Exiv2::IptcData& iptcData,
	       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++;
    }
  return 0;
}


/**
 * Try to find a given key in the xmpData and if a value is
 * found, pass it to 'proc'.
 *
 * @param xmpData metadata set to inspect
 * @param key key to lookup in exifData
 * @param type extractor type to use
 * @param proc function to call with results
 * @param proc_cls closurer for proc
 * @return 0 to continue extracting, 1 to abort
 */
static int
add_xmp_data (const Exiv2::XmpData& xmpData,
	      const std::string& key,
	      enum EXTRACTOR_MetaType type,
	      EXTRACTOR_MetaDataProcessor proc,
	      void *proc_cls)
{
  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++;
    }
  return 0;
}


/**
 * Call 'add_exiv2_tag' for the given key-type combination.
 * Uses 'return' if add_exiv2_tag returns non-0.
 *
 * @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)


/**
 * Call 'add_iptc_data' for the given key-type combination.
 * Uses 'return' if add_iptc_data returns non-0.
 *
 * @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)


/**
 * Call 'add_xmp_data' for the given key-type combination.
 * Uses 'return' if add_xmp_data returns non-0.
 *
 * @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)


/**
 * Main entry method for the 'exiv2' extraction plugin.  
 *
 * @param ec extraction context provided to the plugin
 */
extern "C" void
EXTRACTOR_exiv2_extract_method (struct EXTRACTOR_ExtractContext *ec)
{
  try
    {	    
#if EXIV2_MAKE_VERSION(0,23,0) <= EXIV2_VERSION
      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) 
    {
#if DEBUG
      std::cerr << "Caught Exiv2 exception '" << e << "'\n";
#endif
    }
  catch (void *anything)
    {
    }
}

/* end of exiv2_extractor.cc */