EXIF library (libexif) Internals  0.6.24
exif-entry.c
Go to the documentation of this file.
1 /* exif-entry.c
2  *
3  * Copyright (c) 2001 Lutz Mueller <lutz@users.sourceforge.net>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301 USA.
19  */
20 
21 #include <config.h>
22 
23 #include <libexif/exif-entry.h>
24 #include <libexif/exif-ifd.h>
25 #include <libexif/exif-utils.h>
26 #include <libexif/i18n.h>
27 
28 #include <libexif/exif-gps-ifd.h>
29 
30 #include <ctype.h>
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <string.h>
34 #include <time.h>
35 #include <math.h>
36 
37 #ifndef M_PI
38 #define M_PI 3.14159265358979323846
39 #endif
40 
42 {
43  unsigned int ref_count;
44 
46 };
47 
48 /* This function is hidden in exif-data.c */
50 
51 #ifndef NO_VERBOSE_TAG_STRINGS
52 static void
54 {
55  va_list args;
56  ExifLog *l = NULL;
57 
58  if (e && e->parent && e->parent->parent)
60  va_start (args, format);
61  exif_logv (l, code, "ExifEntry", format, args);
62  va_end (args);
63 }
64 #else
65 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
66 #define exif_entry_log(...) do { } while (0)
67 #elif defined(__GNUC__)
68 #define exif_entry_log(x...) do { } while (0)
69 #else
70 #define exif_entry_log (void)
71 #endif
72 #endif
73 
74 static void *
75 exif_entry_alloc (ExifEntry *e, unsigned int i)
76 {
77  void *d;
78  ExifLog *l = NULL;
79 
80  if (!e || !e->priv || !i) return NULL;
81 
82  d = exif_mem_alloc (e->priv->mem, i);
83  if (d) return d;
84 
85  if (e->parent && e->parent->parent)
87  EXIF_LOG_NO_MEMORY (l, "ExifEntry", i);
88  return NULL;
89 }
90 
91 static void *
92 exif_entry_realloc (ExifEntry *e, void *d_orig, unsigned int i)
93 {
94  void *d;
95  ExifLog *l = NULL;
96 
97  if (!e || !e->priv) return NULL;
98 
99  if (!i) { exif_mem_free (e->priv->mem, d_orig); return NULL; }
100 
101  d = exif_mem_realloc (e->priv->mem, d_orig, i);
102  if (d) return d;
103 
104  if (e->parent && e->parent->parent)
105  l = exif_data_get_log (e->parent->parent);
106  EXIF_LOG_NO_MEMORY (l, "ExifEntry", i);
107  return NULL;
108 }
109 
110 ExifEntry *
112 {
113  ExifMem *mem = exif_mem_new_default ();
114  ExifEntry *e = exif_entry_new_mem (mem);
115 
116  exif_mem_unref (mem);
117 
118  return e;
119 }
120 
121 ExifEntry *
123 {
124  ExifEntry *e = NULL;
125 
126  e = exif_mem_alloc (mem, sizeof (ExifEntry));
127  if (!e) return NULL;
128  e->priv = exif_mem_alloc (mem, sizeof (ExifEntryPrivate));
129  if (!e->priv) { exif_mem_free (mem, e); return NULL; }
130  e->priv->ref_count = 1;
131 
132  e->priv->mem = mem;
133  exif_mem_ref (mem);
134 
135  return e;
136 }
137 
138 void
140 {
141  if (!e) return;
142 
143  e->priv->ref_count++;
144 }
145 
146 void
148 {
149  if (!e) return;
150 
151  e->priv->ref_count--;
152  if (!e->priv->ref_count)
153  exif_entry_free (e);
154 }
155 
156 void
158 {
159  if (!e) return;
160 
161  if (e->priv) {
162  ExifMem *mem = e->priv->mem;
163  if (e->data)
164  exif_mem_free (mem, e->data);
165  exif_mem_free (mem, e->priv);
166  exif_mem_free (mem, e);
167  exif_mem_unref (mem);
168  }
169 }
170 
171 static void
173 {
174  e->components = 0;
175  e->size = 0;
176 }
177 
182 static inline ExifShort
183 exif_get_short_convert (const unsigned char *buf, ExifFormat format,
184  ExifByteOrder order)
185 {
186  switch (format) {
187  case EXIF_FORMAT_LONG:
188  return (ExifShort) exif_get_long (buf, order);
189  case EXIF_FORMAT_SLONG:
190  return (ExifShort) exif_get_slong (buf, order);
191  case EXIF_FORMAT_SHORT:
192  return (ExifShort) exif_get_short (buf, order);
193  case EXIF_FORMAT_SSHORT:
194  return (ExifShort) exif_get_sshort (buf, order);
195  case EXIF_FORMAT_BYTE:
196  case EXIF_FORMAT_SBYTE:
197  return (ExifShort) buf[0];
198  default:
199  /* Unsupported type */
200  return (ExifShort) 0;
201  }
202 }
203 
204 void
206 {
207  unsigned int i, newsize;
208  unsigned char *newdata;
209  ExifByteOrder o;
210  ExifRational r;
211  ExifSRational sr;
212 
213  if (!e || !e->priv) return;
214 
215  switch (e->tag) {
216 
217  /* These tags all need to be of format SHORT. */
231  case EXIF_TAG_SATURATION:
232  case EXIF_TAG_CONTRAST:
233  case EXIF_TAG_SHARPNESS:
235  switch (e->format) {
236  case EXIF_FORMAT_LONG:
237  case EXIF_FORMAT_SLONG:
238  case EXIF_FORMAT_BYTE:
239  case EXIF_FORMAT_SBYTE:
240  case EXIF_FORMAT_SSHORT:
241  if (!e->parent || !e->parent->parent) break;
243  _("Tag '%s' was of format '%s' (which is "
244  "against specification) and has been "
245  "changed to format '%s'."),
247  exif_entry_get_ifd(e)),
250 
253  newdata = exif_entry_alloc (e, newsize);
254  if (!newdata) {
256  "Could not allocate %lu byte(s).", (unsigned long)newsize);
257  break;
258  }
259 
260  for (i = 0; i < e->components; i++)
262  newdata + i *
264  EXIF_FORMAT_SHORT), o,
266  e->data + i *
268  e->format, o));
269 
270  exif_mem_free (e->priv->mem, e->data);
271  e->data = newdata;
272  e->size = newsize;
274  break;
275  case EXIF_FORMAT_SHORT:
276  /* No conversion necessary */
277  break;
278  default:
280  _("Tag '%s' is of format '%s' (which is "
281  "against specification) but cannot be changed "
282  "to format '%s'."),
284  exif_entry_get_ifd(e)),
287  break;
288  }
289  break;
290 
291  /* All these tags need to be of format 'Rational'. */
292  case EXIF_TAG_FNUMBER:
296  switch (e->format) {
298  if (!e->parent || !e->parent->parent) break;
300  for (i = 0; i < e->components; i++) {
301  sr = exif_get_srational (e->data + i *
304  r.numerator = (ExifLong) sr.numerator;
306  exif_set_rational (e->data + i *
308  EXIF_FORMAT_RATIONAL), o, r);
309  }
312  _("Tag '%s' was of format '%s' (which is "
313  "against specification) and has been "
314  "changed to format '%s'."),
316  exif_entry_get_ifd(e)),
319  break;
320  default:
321  break;
322  }
323  break;
324 
325  /* All these tags need to be of format 'SRational'. */
329  switch (e->format) {
331  if (!e->parent || !e->parent->parent) break;
333  for (i = 0; i < e->components; i++) {
334  r = exif_get_rational (e->data + i *
337  sr.numerator = (ExifLong) r.numerator;
339  exif_set_srational (e->data + i *
341  EXIF_FORMAT_SRATIONAL), o, sr);
342  }
345  _("Tag '%s' was of format '%s' (which is "
346  "against specification) and has been "
347  "changed to format '%s'."),
349  exif_entry_get_ifd(e)),
352  break;
353  default:
354  break;
355  }
356  break;
357 
359 
360  /* Format needs to be UNDEFINED. */
361  if (e->format != EXIF_FORMAT_UNDEFINED) {
363  _("Tag 'UserComment' had invalid format '%s'. "
364  "Format has been set to 'undefined'."),
367  }
368 
369  /* Some packages like Canon ZoomBrowser EX 4.5 store
370  only one zero byte followed by 7 bytes of rubbish */
371  if ((e->size >= 8) && (e->data[0] == 0)) {
372  memcpy(e->data, "\0\0\0\0\0\0\0\0", 8);
373  }
374 
375  /* There need to be at least 8 bytes. */
376  if (e->size < 8) {
377  e->data = exif_entry_realloc (e, e->data, 8 + e->size);
378  if (!e->data) {
379  clear_entry(e);
380  return;
381  }
382 
383  /* Assume ASCII */
384  memmove (e->data + 8, e->data, e->size);
385  memcpy (e->data, "ASCII\0\0\0", 8);
386  e->size += 8;
387  e->components += 8;
389  _("Tag 'UserComment' has been expanded to at "
390  "least 8 bytes in order to follow the "
391  "specification."));
392  break;
393  }
394 
395  /*
396  * If the first 8 bytes are empty and real data starts
397  * afterwards, let's assume ASCII and claim the 8 first
398  * bytes for the format specifyer.
399  */
400  for (i = 0; (i < e->size) && !e->data[i]; i++);
401  if (!i) for ( ; (i < e->size) && (e->data[i] == ' '); i++);
402  if ((i >= 8) && (i < e->size)) {
404  _("Tag 'UserComment' is not empty but does not "
405  "start with a format identifier. "
406  "This has been fixed."));
407  memcpy (e->data, "ASCII\0\0\0", 8);
408  break;
409  }
410 
411  /*
412  * First 8 bytes need to follow the specification. If they don't,
413  * assume ASCII.
414  */
415  if (memcmp (e->data, "ASCII\0\0\0" , 8) &&
416  memcmp (e->data, "UNICODE\0" , 8) &&
417  memcmp (e->data, "JIS\0\0\0\0\0" , 8) &&
418  memcmp (e->data, "\0\0\0\0\0\0\0\0", 8)) {
419  e->data = exif_entry_realloc (e, e->data, 8 + e->size);
420  if (!e->data) {
421  clear_entry(e);
422  break;
423  }
424 
425  /* Assume ASCII */
426  memmove (e->data + 8, e->data, e->size);
427  memcpy (e->data, "ASCII\0\0\0", 8);
428  e->size += 8;
429  e->components += 8;
431  _("Tag 'UserComment' did not start with a "
432  "format identifier. This has been fixed."));
433  break;
434  }
435 
436  break;
437  default:
438  break;
439  }
440 }
441 
450 static void
451 exif_entry_format_value(ExifEntry *e, char *val, size_t maxlen)
452 {
453  ExifByte v_byte;
454  ExifShort v_short;
455  ExifSShort v_sshort;
456  ExifLong v_long;
457  ExifRational v_rat;
458  ExifSRational v_srat;
459  ExifSLong v_slong;
460  unsigned int i;
461  size_t len;
463 
464  if (!e->size || !maxlen)
465  return;
466  switch (e->format) {
468  snprintf (val, maxlen, _("%i bytes undefined data"), e->size);
469  break;
470  case EXIF_FORMAT_BYTE:
471  case EXIF_FORMAT_SBYTE:
472  v_byte = e->data[0];
473  snprintf (val, maxlen, "0x%02x", v_byte);
474  len = strlen (val);
475  for (i = 1; i < e->components; i++) {
476  v_byte = e->data[i];
477  snprintf (val+len, maxlen-len, ", 0x%02x", v_byte);
478  len += strlen (val+len);
479  if (len >= maxlen-1) break;
480  }
481  break;
482  case EXIF_FORMAT_SHORT:
483  v_short = exif_get_short (e->data, o);
484  snprintf (val, maxlen, "%u", v_short);
485  len = strlen (val);
486  for (i = 1; i < e->components; i++) {
487  v_short = exif_get_short (e->data +
488  exif_format_get_size (e->format) * i, o);
489  snprintf (val+len, maxlen-len, ", %u", v_short);
490  len += strlen (val+len);
491  if (len >= maxlen-1) break;
492  }
493  break;
494  case EXIF_FORMAT_SSHORT:
495  v_sshort = exif_get_sshort (e->data, o);
496  snprintf (val, maxlen, "%i", v_sshort);
497  len = strlen (val);
498  for (i = 1; i < e->components; i++) {
499  v_sshort = exif_get_short (e->data +
501  i, o);
502  snprintf (val+len, maxlen-len, ", %i", v_sshort);
503  len += strlen (val+len);
504  if (len >= maxlen-1) break;
505  }
506  break;
507  case EXIF_FORMAT_LONG:
508  v_long = exif_get_long (e->data, o);
509  snprintf (val, maxlen, "%lu", (unsigned long) v_long);
510  len = strlen (val);
511  for (i = 1; i < e->components; i++) {
512  v_long = exif_get_long (e->data +
514  i, o);
515  snprintf (val+len, maxlen-len, ", %lu", (unsigned long) v_long);
516  len += strlen (val+len);
517  if (len >= maxlen-1) break;
518  }
519  break;
520  case EXIF_FORMAT_SLONG:
521  v_slong = exif_get_slong (e->data, o);
522  snprintf (val, maxlen, "%li", (long) v_slong);
523  len = strlen (val);
524  for (i = 1; i < e->components; i++) {
525  v_slong = exif_get_slong (e->data +
526  exif_format_get_size (e->format) * i, o);
527  snprintf (val+len, maxlen-len, ", %li", (long) v_slong);
528  len += strlen (val+len);
529  if (len >= maxlen-1) break;
530  }
531  break;
532  case EXIF_FORMAT_ASCII:
533  strncpy (val, (char *) e->data, MIN (maxlen-1, e->size));
534  val[MIN (maxlen-1, e->size)] = 0;
535  break;
537  len = 0;
538  for (i = 0; i < e->components; i++) {
539  if (i > 0) {
540  snprintf (val+len, maxlen-len, ", ");
541  len += strlen (val+len);
542  }
543  v_rat = exif_get_rational (
544  e->data + 8 * i, o);
545  if (v_rat.denominator) {
546  /*
547  * Choose the number of significant digits to
548  * display based on the size of the denominator.
549  * It is scaled so that denominators within the
550  * range 13..120 will show 2 decimal points.
551  */
552  int decimals = (int)(log10(v_rat.denominator)-0.08+1.0);
553  snprintf (val+len, maxlen-len, "%2.*f",
554  decimals,
555  (double) v_rat.numerator /
556  (double) v_rat.denominator);
557  } else
558  snprintf (val+len, maxlen-len, "%lu/%lu",
559  (unsigned long) v_rat.numerator,
560  (unsigned long) v_rat.denominator);
561  len += strlen (val+len);
562  if (len >= maxlen-1) break;
563  }
564  break;
566  len = 0;
567  for (i = 0; i < e->components; i++) {
568  if (i > 0) {
569  snprintf (val+len, maxlen-len, ", ");
570  len += strlen (val+len);
571  }
572  v_srat = exif_get_srational (
573  e->data + 8 * i, o);
574  if (v_srat.denominator) {
575  int decimals = (int)(log10(abs(v_srat.denominator))-0.08+1.0);
576  snprintf (val+len, maxlen-len, "%2.*f",
577  decimals,
578  (double) v_srat.numerator /
579  (double) v_srat.denominator);
580  } else
581  snprintf (val+len, maxlen-len, "%li/%li",
582  (long) v_srat.numerator,
583  (long) v_srat.denominator);
584  len += strlen (val+len);
585  if (len >= maxlen-1) break;
586  }
587  break;
588  case EXIF_FORMAT_DOUBLE:
589  case EXIF_FORMAT_FLOAT:
590  default:
591  snprintf (val, maxlen, _("%i bytes unsupported data type"),
592  e->size);
593  break;
594  }
595 }
596 
597 void
598 exif_entry_dump (ExifEntry *e, unsigned int indent)
599 {
600  char buf[1024];
601  char value[1024];
602  unsigned int l;
603 
604  if (!e)
605  return;
606 
607  l = MIN(sizeof(buf)-1, 2*indent);
608  memset(buf, ' ', l);
609  buf[l] = '\0';
610 
611  printf ("%sTag: 0x%x ('%s')\n", buf, e->tag,
613  printf ("%s Format: %i ('%s')\n", buf, e->format,
615  printf ("%s Components: %i\n", buf, (int) e->components);
616  printf ("%s Size: %i\n", buf, e->size);
617  printf ("%s Value: %s\n", buf, exif_entry_get_value (e, value, sizeof(value)));
618 }
619 
629 static int
630 match_repeated_char(const unsigned char *data, unsigned char ch, size_t n)
631 {
632  int i;
633  for (i=n; i; --i, ++data) {
634  if (*data == 0) {
635  i = 0; /* all bytes before NUL matched */
636  break;
637  }
638  if (*data != ch)
639  break;
640  }
641  return i;
642 }
643 
644 #define CF(entry,target,v,maxlen) \
645 { \
646  if (entry->format != target) { \
647  exif_entry_log (entry, EXIF_LOG_CODE_CORRUPT_DATA, \
648  _("The tag '%s' contains data of an invalid " \
649  "format ('%s', expected '%s')."), \
650  exif_tag_get_name (entry->tag), \
651  exif_format_get_name (entry->format), \
652  exif_format_get_name (target)); \
653  break; \
654  } \
655 }
656 
657 #define CC(entry,target,v,maxlen) \
658 { \
659  if (entry->components != target) { \
660  exif_entry_log (entry, EXIF_LOG_CODE_CORRUPT_DATA, \
661  _("The tag '%s' contains an invalid number of " \
662  "components (%i, expected %i)."), \
663  exif_tag_get_name (entry->tag), \
664  (int) entry->components, (int) target); \
665  break; \
666  } \
667 }
668 
669 static const struct {
671  const char *strings[10];
672 } list[] = {
673 #ifndef NO_VERBOSE_TAG_DATA
675  { N_("Chunky format"), N_("Planar format"), NULL}},
677  { "", N_("Not defined"), N_("One-chip color area sensor"),
678  N_("Two-chip color area sensor"), N_("Three-chip color area sensor"),
679  N_("Color sequential area sensor"), "", N_("Trilinear sensor"),
680  N_("Color sequential linear sensor"), NULL}},
682  { "", N_("Top-left"), N_("Top-right"), N_("Bottom-right"),
683  N_("Bottom-left"), N_("Left-top"), N_("Right-top"),
684  N_("Right-bottom"), N_("Left-bottom"), NULL}},
686  { "", N_("Centered"), N_("Co-sited"), NULL}},
688  { N_("Reversed mono"), N_("Normal mono"), N_("RGB"), N_("Palette"), "",
689  N_("CMYK"), N_("YCbCr"), "", N_("CieLAB"), NULL}},
691  { N_("Normal process"), N_("Custom process"), NULL}},
693  { N_("Auto exposure"), N_("Manual exposure"), N_("Auto bracket"), NULL}},
695  { N_("Auto white balance"), N_("Manual white balance"), NULL}},
697  { N_("Standard"), N_("Landscape"), N_("Portrait"),
698  N_("Night scene"), NULL}},
700  { N_("Normal"), N_("Low gain up"), N_("High gain up"),
701  N_("Low gain down"), N_("High gain down"), NULL}},
703  { N_("Normal"), N_("Low saturation"), N_("High saturation"), NULL}},
704  { EXIF_TAG_CONTRAST , {N_("Normal"), N_("Soft"), N_("Hard"), NULL}},
705  { EXIF_TAG_SHARPNESS, {N_("Normal"), N_("Soft"), N_("Hard"), NULL}},
706 #endif
707  { 0, {NULL}}
708 };
709 
710 static const struct {
711  ExifTag tag;
712  struct {
714  const char *values[4];
717  } elem[25];
718 } list2[] = {
719 #ifndef NO_VERBOSE_TAG_DATA
721  { { 0, {N_("Unknown"), NULL}},
722  { 1, {N_("Average"), N_("Avg"), NULL}},
723  { 2, {N_("Center-weighted average"), N_("Center-weight"), NULL}},
724  { 3, {N_("Spot"), NULL}},
725  { 4, {N_("Multi spot"), NULL}},
726  { 5, {N_("Pattern"), NULL}},
727  { 6, {N_("Partial"), NULL}},
728  {255, {N_("Other"), NULL}},
729  { 0, {NULL}}}},
731  { {1, {N_("Uncompressed"), NULL}},
732  {5, {N_("LZW compression"), NULL}},
733  {6, {N_("JPEG compression"), NULL}},
734  {7, {N_("JPEG compression"), NULL}},
735  {8, {N_("Deflate/ZIP compression"), NULL}},
736  {32773, {N_("PackBits compression"), NULL}},
737  {0, {NULL}}}},
739  { { 0, {N_("Unknown"), NULL}},
740  { 1, {N_("Daylight"), NULL}},
741  { 2, {N_("Fluorescent"), NULL}},
742  { 3, {N_("Tungsten incandescent light"), N_("Tungsten"), NULL}},
743  { 4, {N_("Flash"), NULL}},
744  { 9, {N_("Fine weather"), NULL}},
745  { 10, {N_("Cloudy weather"), N_("Cloudy"), NULL}},
746  { 11, {N_("Shade"), NULL}},
747  { 12, {N_("Daylight fluorescent"), NULL}},
748  { 13, {N_("Day white fluorescent"), NULL}},
749  { 14, {N_("Cool white fluorescent"), NULL}},
750  { 15, {N_("White fluorescent"), NULL}},
751  { 17, {N_("Standard light A"), NULL}},
752  { 18, {N_("Standard light B"), NULL}},
753  { 19, {N_("Standard light C"), NULL}},
754  { 20, {N_("D55"), NULL}},
755  { 21, {N_("D65"), NULL}},
756  { 22, {N_("D75"), NULL}},
757  { 24, {N_("ISO studio tungsten"),NULL}},
758  {255, {N_("Other"), NULL}},
759  { 0, {NULL}}}},
761  { {2, {N_("Inch"), N_("in"), NULL}},
762  {3, {N_("Centimeter"), N_("cm"), NULL}},
763  {0, {NULL}}}},
765  { {2, {N_("Inch"), N_("in"), NULL}},
766  {3, {N_("Centimeter"), N_("cm"), NULL}},
767  {0, {NULL}}}},
769  { {0, {N_("Not defined"), NULL}},
770  {1, {N_("Manual"), NULL}},
771  {2, {N_("Normal program"), N_("Normal"), NULL}},
772  {3, {N_("Aperture priority"), N_("Aperture"), NULL}},
773  {4, {N_("Shutter priority"),N_("Shutter"), NULL}},
774  {5, {N_("Creative program (biased toward depth of field)"),
775  N_("Creative"), NULL}},
776  {6, {N_("Creative program (biased toward fast shutter speed)"),
777  N_("Action"), NULL}},
778  {7, {N_("Portrait mode (for closeup photos with the background out "
779  "of focus)"), N_("Portrait"), NULL}},
780  {8, {N_("Landscape mode (for landscape photos with the background "
781  "in focus)"), N_("Landscape"), NULL}},
782  {0, {NULL}}}},
784  { {0, {N_("Unknown"), NULL}},
785  {1, {N_("Standard output sensitivity (SOS)"), NULL}},
786  {2, {N_("Recommended exposure index (REI)"), NULL}},
787  {3, {N_("ISO speed"), NULL}},
788  {4, {N_("Standard output sensitivity (SOS) and recommended exposure index (REI)"), NULL}},
789  {5, {N_("Standard output sensitivity (SOS) and ISO speed"), NULL}},
790  {6, {N_("Recommended exposure index (REI) and ISO speed"), NULL}},
791  {7, {N_("Standard output sensitivity (SOS) and recommended exposure index (REI) and ISO speed"), NULL}},
792  {0, {NULL}}}},
793  { EXIF_TAG_FLASH,
794  { {0x0000, {N_("Flash did not fire"), N_("No flash"), NULL}},
795  {0x0001, {N_("Flash fired"), N_("Flash"), N_("Yes"), NULL}},
796  {0x0005, {N_("Strobe return light not detected"), N_("Without strobe"),
797  NULL}},
798  {0x0007, {N_("Strobe return light detected"), N_("With strobe"), NULL}},
799  {0x0008, {N_("Flash did not fire"), NULL}}, /* Olympus E-330 */
800  {0x0009, {N_("Flash fired, compulsory flash mode"), NULL}},
801  {0x000d, {N_("Flash fired, compulsory flash mode, return light "
802  "not detected"), NULL}},
803  {0x000f, {N_("Flash fired, compulsory flash mode, return light "
804  "detected"), NULL}},
805  {0x0010, {N_("Flash did not fire, compulsory flash mode"), NULL}},
806  {0x0018, {N_("Flash did not fire, auto mode"), NULL}},
807  {0x0019, {N_("Flash fired, auto mode"), NULL}},
808  {0x001d, {N_("Flash fired, auto mode, return light not detected"),
809  NULL}},
810  {0x001f, {N_("Flash fired, auto mode, return light detected"), NULL}},
811  {0x0020, {N_("No flash function"),NULL}},
812  {0x0041, {N_("Flash fired, red-eye reduction mode"), NULL}},
813  {0x0045, {N_("Flash fired, red-eye reduction mode, return light "
814  "not detected"), NULL}},
815  {0x0047, {N_("Flash fired, red-eye reduction mode, return light "
816  "detected"), NULL}},
817  {0x0049, {N_("Flash fired, compulsory flash mode, red-eye reduction "
818  "mode"), NULL}},
819  {0x004d, {N_("Flash fired, compulsory flash mode, red-eye reduction "
820  "mode, return light not detected"), NULL}},
821  {0x004f, {N_("Flash fired, compulsory flash mode, red-eye reduction mode, "
822  "return light detected"), NULL}},
823  {0x0058, {N_("Flash did not fire, auto mode, red-eye reduction mode"), NULL}},
824  {0x0059, {N_("Flash fired, auto mode, red-eye reduction mode"), NULL}},
825  {0x005d, {N_("Flash fired, auto mode, return light not detected, "
826  "red-eye reduction mode"), NULL}},
827  {0x005f, {N_("Flash fired, auto mode, return light detected, "
828  "red-eye reduction mode"), NULL}},
829  {0x0000, {NULL}}}},
831  { {0, {N_("Unknown"), N_("?"), NULL}},
832  {1, {N_("Macro"), NULL}},
833  {2, {N_("Close view"), N_("Close"), NULL}},
834  {3, {N_("Distant view"), N_("Distant"), NULL}},
835  {0, {NULL}}}},
837  { {1, {N_("sRGB"), NULL}},
838  {2, {N_("Adobe RGB"), NULL}},
839  {0xffff, {N_("Uncalibrated"), NULL}},
840  {0x0000, {NULL}}}},
841 #endif
842  {0, { { 0, {NULL}}} }
843 };
844 
845 const char *
846 exif_entry_get_value (ExifEntry *e, char *val, unsigned int maxlen)
847 {
848  unsigned int i, j, k;
849  ExifShort v_short, v_short2, v_short3, v_short4;
850  ExifByte v_byte;
851  ExifRational v_rat;
852  ExifSRational v_srat;
853  char b[64];
854  const char *c;
855  ExifByteOrder o;
856  double d;
857  ExifEntry *entry;
858  static const struct {
859  char label[5];
860  char major, minor;
861  } versions[] = {
862  {"0110", 1, 1},
863  {"0120", 1, 2},
864  {"0200", 2, 0},
865  {"0210", 2, 1},
866  {"0220", 2, 2},
867  {"0221", 2, 21},
868  {"0230", 2, 3},
869  {"0231", 2, 31},
870  {"0232", 2, 32},
871  {"" , 0, 0}
872  };
873 
874  (void) bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
875 
876  if (!e || !e->parent || !e->parent->parent || !maxlen || !val)
877  return val;
878 
879  /* make sure the returned string is zero terminated */
880  /* FIXME: this is inefficient in the case of long buffers and should
881  * instead be taken care of on each write instead. */
882  memset (val, 0, maxlen);
883 
884  /* We need the byte order */
886 
887  /* Sanity check */
888  if (e->size != e->components * exif_format_get_size (e->format)) {
889  snprintf (val, maxlen, _("Invalid size of entry (%i, "
890  "expected %li x %i)."), e->size, e->components,
892  return val;
893  }
894 
895  switch (e->tag) {
897 
898  /*
899  * The specification says UNDEFINED, but some
900  * manufacturers don't care and use ASCII. If this is the
901  * case here, only refuse to read it if there is no chance
902  * of finding readable data.
903  */
904  if ((e->format != EXIF_FORMAT_ASCII) ||
905  (e->size <= 8) ||
906  ( memcmp (e->data, "ASCII\0\0\0" , 8) &&
907  memcmp (e->data, "UNICODE\0" , 8) &&
908  memcmp (e->data, "JIS\0\0\0\0\0", 8) &&
909  memcmp (e->data, "\0\0\0\0\0\0\0\0", 8)))
910  CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
911 
912  /*
913  * Note that, according to the specification (V2.1, p 40),
914  * the user comment field does not have to be
915  * NULL terminated.
916  */
917  if ((e->size >= 8) && !memcmp (e->data, "ASCII\0\0\0", 8)) {
918  strncpy (val, (char *) e->data + 8, MIN (e->size - 8, maxlen-1));
919  break;
920  }
921  if ((e->size >= 8) && !memcmp (e->data, "UNICODE\0", 8)) {
922  strncpy (val, _("Unsupported UNICODE string"), maxlen-1);
923  /* FIXME: use iconv to convert into the locale encoding.
924  * EXIF 2.2 implies (but does not say) that this encoding is
925  * UCS-2.
926  */
927  break;
928  }
929  if ((e->size >= 8) && !memcmp (e->data, "JIS\0\0\0\0\0", 8)) {
930  strncpy (val, _("Unsupported JIS string"), maxlen-1);
931  /* FIXME: use iconv to convert into the locale encoding */
932  break;
933  }
934 
935  /* Check if there is really some information in the tag. */
936  for (i = 0; (i < e->size) &&
937  (!e->data[i] || (e->data[i] == ' ')); i++);
938  if (i == e->size) break;
939 
940  /*
941  * If we reach this point, the tag does not
942  * comply with the standard but seems to contain data.
943  * Print as much as possible.
944  * Note: make sure we do not overwrite the final \0 at maxlen-1
945  */
947  _("Tag UserComment contains data but is "
948  "against specification."));
949  for (j = 0; (i < e->size) && (j < maxlen-1); i++, j++) {
951  _("Byte at position %i: 0x%02x"), i, e->data[i]);
952  val[j] = isprint (e->data[i]) ? e->data[i] : '.';
953  }
954  break;
955 
957  CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
958  CC (e, 4, val, maxlen);
959  strncpy (val, _("Unknown Exif Version"), maxlen-1);
960  for (i = 0; *versions[i].label; i++) {
961  if (!memcmp (e->data, versions[i].label, 4)) {
962  snprintf (val, maxlen,
963  _("Exif Version %d.%d"),
964  versions[i].major,
965  versions[i].minor);
966  break;
967  }
968  }
969  break;
971  CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
972  CC (e, 4, val, maxlen);
973  if (!memcmp (e->data, "0100", 4))
974  strncpy (val, _("FlashPix Version 1.0"), maxlen-1);
975  else if (!memcmp (e->data, "0101", 4))
976  strncpy (val, _("FlashPix Version 1.01"), maxlen-1);
977  else
978  strncpy (val, _("Unknown FlashPix Version"), maxlen-1);
979  break;
980  case EXIF_TAG_COPYRIGHT:
981  CF (e, EXIF_FORMAT_ASCII, val, maxlen);
982 
983  /*
984  * First part: Photographer.
985  * Some cameras store a string like " " here. Ignore it.
986  * Remember that a corrupted tag might not be NUL-terminated
987  */
988  if (e->size && e->data && match_repeated_char(e->data, ' ', e->size))
989  strncpy (val, (char *) e->data, MIN (maxlen-1, e->size));
990  else
991  strncpy (val, _("[None]"), maxlen-1);
992  strncat (val, " ", maxlen-1 - strlen (val));
993  strncat (val, _("(Photographer)"), maxlen-1 - strlen (val));
994 
995  /* Second part: Editor. */
996  strncat (val, " - ", maxlen-1 - strlen (val));
997  k = 0;
998  if (e->size && e->data) {
999  const unsigned char *tagdata = memchr(e->data, 0, e->size);
1000  if (tagdata++) {
1001  unsigned int editor_ofs = tagdata - e->data;
1002  unsigned int remaining = e->size - editor_ofs;
1003  if (match_repeated_char(tagdata, ' ', remaining)) {
1004  strncat (val, (const char*)tagdata, MIN (maxlen-1 - strlen (val), remaining));
1005  ++k;
1006  }
1007  }
1008  }
1009  if (!k)
1010  strncat (val, _("[None]"), maxlen-1 - strlen (val));
1011  strncat (val, " ", maxlen-1 - strlen (val));
1012  strncat (val, _("(Editor)"), maxlen-1 - strlen (val));
1013 
1014  break;
1015  case EXIF_TAG_FNUMBER:
1016  CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
1017  CC (e, 1, val, maxlen);
1018  v_rat = exif_get_rational (e->data, o);
1019  if (!v_rat.denominator) {
1020  exif_entry_format_value(e, val, maxlen);
1021  break;
1022  }
1023  d = (double) v_rat.numerator / (double) v_rat.denominator;
1024  snprintf (val, maxlen, "f/%.01f", d);
1025  break;
1028  CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
1029  CC (e, 1, val, maxlen);
1030  v_rat = exif_get_rational (e->data, o);
1031  if (!v_rat.denominator || (0x80000000 == v_rat.numerator)) {
1032  exif_entry_format_value(e, val, maxlen);
1033  break;
1034  }
1035  d = (double) v_rat.numerator / (double) v_rat.denominator;
1036  snprintf (val, maxlen, _("%.02f EV"), d);
1037  snprintf (b, sizeof (b), _(" (f/%.01f)"), pow (2, d / 2.));
1038  strncat (val, b, maxlen-1 - strlen (val));
1039  break;
1040  case EXIF_TAG_FOCAL_LENGTH:
1041  CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
1042  CC (e, 1, val, maxlen);
1043  v_rat = exif_get_rational (e->data, o);
1044  if (!v_rat.denominator) {
1045  exif_entry_format_value(e, val, maxlen);
1046  break;
1047  }
1048 
1049  /*
1050  * For calculation of the 35mm equivalent,
1051  * Minolta cameras need a multiplier that depends on the
1052  * camera model.
1053  */
1054  d = 0.;
1055  entry = exif_content_get_entry (
1057  if (entry && entry->data && entry->size >= 7 &&
1058  !strncmp ((char *)entry->data, "Minolta", 7)) {
1059  entry = exif_content_get_entry (
1060  e->parent->parent->ifd[EXIF_IFD_0],
1061  EXIF_TAG_MODEL);
1062  if (entry && entry->data && entry->size >= 8) {
1063  if (!strncmp ((char *)entry->data, "DiMAGE 7", 8))
1064  d = 3.9;
1065  else if (!strncmp ((char *)entry->data, "DiMAGE 5", 8))
1066  d = 4.9;
1067  }
1068  }
1069  if (d)
1070  snprintf (b, sizeof (b), _(" (35 equivalent: %.0f mm)"),
1071  (d * (double) v_rat.numerator /
1072  (double) v_rat.denominator));
1073  else
1074  b[0] = 0;
1075 
1076  d = (double) v_rat.numerator / (double) v_rat.denominator;
1077  snprintf (val, maxlen, "%.1f mm", d);
1078  strncat (val, b, maxlen-1 - strlen (val));
1079  break;
1081  CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
1082  CC (e, 1, val, maxlen);
1083  v_rat = exif_get_rational (e->data, o);
1084  if (!v_rat.denominator) {
1085  exif_entry_format_value(e, val, maxlen);
1086  break;
1087  }
1088  d = (double) v_rat.numerator / (double) v_rat.denominator;
1089  snprintf (val, maxlen, "%.1f m", d);
1090  break;
1092  CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
1093  CC (e, 1, val, maxlen);
1094  v_rat = exif_get_rational (e->data, o);
1095  if (!v_rat.denominator) {
1096  exif_entry_format_value(e, val, maxlen);
1097  break;
1098  }
1099  d = (double) v_rat.numerator / (double) v_rat.denominator;
1100  if (d < 1 && d)
1101  snprintf (val, maxlen, _("1/%.0f"), 1. / d);
1102  else
1103  snprintf (val, maxlen, "%.0f", d);
1104  strncat (val, _(" sec."), maxlen-1 - strlen (val));
1105  break;
1107  CF (e, EXIF_FORMAT_SRATIONAL, val, maxlen);
1108  CC (e, 1, val, maxlen);
1109  v_srat = exif_get_srational (e->data, o);
1110  if (!v_srat.denominator) {
1111  exif_entry_format_value(e, val, maxlen);
1112  break;
1113  }
1114  d = (double) v_srat.numerator / (double) v_srat.denominator;
1115  snprintf (val, maxlen, _("%.02f EV"), d);
1116  if (pow (2, d))
1117  d = 1. / pow (2, d);
1118  if (d < 1 && d)
1119  snprintf (b, sizeof (b), _(" (1/%.0f sec.)"), 1. / d);
1120  else
1121  snprintf (b, sizeof (b), _(" (%.0f sec.)"), d);
1122  strncat (val, b, maxlen-1 - strlen (val));
1123  break;
1125  CF (e, EXIF_FORMAT_SRATIONAL, val, maxlen);
1126  CC (e, 1, val, maxlen);
1127  v_srat = exif_get_srational (e->data, o);
1128  if (!v_srat.denominator) {
1129  exif_entry_format_value(e, val, maxlen);
1130  break;
1131  }
1132  d = (double) v_srat.numerator / (double) v_srat.denominator;
1133  snprintf (val, maxlen, _("%.02f EV"), d);
1134  snprintf (b, sizeof (b), _(" (%.02f cd/m^2)"),
1135  1. / (M_PI * 0.3048 * 0.3048) * pow (2, d));
1136  strncat (val, b, maxlen-1 - strlen (val));
1137  break;
1138  case EXIF_TAG_FILE_SOURCE:
1139  CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
1140  CC (e, 1, val, maxlen);
1141  v_byte = e->data[0];
1142  if (v_byte == 3)
1143  strncpy (val, _("DSC"), maxlen-1);
1144  else
1145  snprintf (val, maxlen, _("Internal error (unknown "
1146  "value %i)"), v_byte);
1147  break;
1149  CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
1150  CC (e, 4, val, maxlen);
1151  for (i = 0; i < 4; i++) {
1152  switch (e->data[i]) {
1153  case 0: c = _("-"); break;
1154  case 1: c = _("Y"); break;
1155  case 2: c = _("Cb"); break;
1156  case 3: c = _("Cr"); break;
1157  case 4: c = _("R"); break;
1158  case 5: c = _("G"); break;
1159  case 6: c = _("B"); break;
1160  default: c = _("Reserved"); break;
1161  }
1162  strncat (val, c, maxlen-1 - strlen (val));
1163  if (i < 3)
1164  strncat (val, " ", maxlen-1 - strlen (val));
1165  }
1166  break;
1168  CF (e, EXIF_FORMAT_SRATIONAL, val, maxlen);
1169  CC (e, 1, val, maxlen);
1170  v_srat = exif_get_srational (e->data, o);
1171  if (!v_srat.denominator) {
1172  exif_entry_format_value(e, val, maxlen);
1173  break;
1174  }
1175  d = (double) v_srat.numerator / (double) v_srat.denominator;
1176  snprintf (val, maxlen, _("%.02f EV"), d);
1177  break;
1178  case EXIF_TAG_SCENE_TYPE:
1179  CF (e, EXIF_FORMAT_UNDEFINED, val, maxlen);
1180  CC (e, 1, val, maxlen);
1181  v_byte = e->data[0];
1182  if (v_byte == 1)
1183  strncpy (val, _("Directly photographed"), maxlen-1);
1184  else
1185  snprintf (val, maxlen, _("Internal error (unknown "
1186  "value %i)"), v_byte);
1187  break;
1189  CF (e, EXIF_FORMAT_SHORT, val, maxlen);
1190  CC (e, 2, val, maxlen);
1191  v_short = exif_get_short (e->data, o);
1192  v_short2 = exif_get_short (
1193  e->data + exif_format_get_size (e->format),
1194  o);
1195  if ((v_short == 2) && (v_short2 == 1))
1196  strncpy (val, _("YCbCr4:2:2"), maxlen-1);
1197  else if ((v_short == 2) && (v_short2 == 2))
1198  strncpy (val, _("YCbCr4:2:0"), maxlen-1);
1199  else
1200  snprintf (val, maxlen, "%u, %u", v_short, v_short2);
1201  break;
1202  case EXIF_TAG_SUBJECT_AREA:
1203  CF (e, EXIF_FORMAT_SHORT, val, maxlen);
1204  switch (e->components) {
1205  case 2:
1206  v_short = exif_get_short (e->data, o);
1207  v_short2 = exif_get_short (e->data + 2, o);
1208  snprintf (val, maxlen, "(x,y) = (%i,%i)",
1209  v_short, v_short2);
1210  break;
1211  case 3:
1212  v_short = exif_get_short (e->data, o);
1213  v_short2 = exif_get_short (e->data + 2, o);
1214  v_short3 = exif_get_short (e->data + 4, o);
1215  snprintf (val, maxlen, _("Within distance %i of "
1216  "(x,y) = (%i,%i)"), v_short3, v_short,
1217  v_short2);
1218  break;
1219  case 4:
1220  v_short = exif_get_short (e->data, o);
1221  v_short2 = exif_get_short (e->data + 2, o);
1222  v_short3 = exif_get_short (e->data + 4, o);
1223  v_short4 = exif_get_short (e->data + 6, o);
1224  snprintf (val, maxlen, _("Within rectangle "
1225  "(width %i, height %i) around "
1226  "(x,y) = (%i,%i)"), v_short3, v_short4,
1227  v_short, v_short2);
1228  break;
1229  default:
1230  snprintf (val, maxlen, _("Unexpected number "
1231  "of components (%li, expected 2, 3, or 4)."),
1232  e->components);
1233  }
1234  break;
1236  /* This is only valid in the GPS IFD */
1237  CF (e, EXIF_FORMAT_BYTE, val, maxlen);
1238  CC (e, 4, val, maxlen);
1239  v_byte = e->data[0];
1240  snprintf (val, maxlen, "%u", v_byte);
1241  for (i = 1; i < e->components; i++) {
1242  v_byte = e->data[i];
1243  snprintf (b, sizeof (b), ".%u", v_byte);
1244  strncat (val, b, maxlen-1 - strlen (val));
1245  }
1246  break;
1248  /* a.k.a. case EXIF_TAG_GPS_LATITUDE: */
1249  /* This tag occurs in EXIF_IFD_INTEROPERABILITY */
1250  if (e->format == EXIF_FORMAT_UNDEFINED) {
1251  strncpy (val, (char *) e->data, MIN (maxlen-1, e->size));
1252  break;
1253  }
1254  /* EXIF_TAG_GPS_LATITUDE is the same numerically as
1255  * EXIF_TAG_INTEROPERABILITY_VERSION but in EXIF_IFD_GPS
1256  */
1257  exif_entry_format_value(e, val, maxlen);
1258  break;
1260  /* This is only valid in the GPS IFD */
1261  CF (e, EXIF_FORMAT_BYTE, val, maxlen);
1262  CC (e, 1, val, maxlen);
1263  v_byte = e->data[0];
1264  if (v_byte == 0)
1265  strncpy (val, _("Sea level"), maxlen-1);
1266  else if (v_byte == 1)
1267  strncpy (val, _("Sea level reference"), maxlen-1);
1268  else
1269  snprintf (val, maxlen, _("Internal error (unknown "
1270  "value %i)"), v_byte);
1271  break;
1273  /* This is only valid in the GPS IFD */
1274  CF (e, EXIF_FORMAT_RATIONAL, val, maxlen);
1275  CC (e, 3, val, maxlen);
1276 
1277  v_rat = exif_get_rational (e->data, o);
1278  if (!v_rat.denominator) {
1279  exif_entry_format_value(e, val, maxlen);
1280  break;
1281  }
1282  i = v_rat.numerator / v_rat.denominator;
1283 
1284  v_rat = exif_get_rational (e->data +
1286  o);
1287  if (!v_rat.denominator) {
1288  exif_entry_format_value(e, val, maxlen);
1289  break;
1290  }
1291  j = v_rat.numerator / v_rat.denominator;
1292 
1293  v_rat = exif_get_rational (e->data +
1295  o);
1296  if (!v_rat.denominator) {
1297  exif_entry_format_value(e, val, maxlen);
1298  break;
1299  }
1300  d = (double) v_rat.numerator / (double) v_rat.denominator;
1301  snprintf (val, maxlen, "%02u:%02u:%05.2f", i, j, d);
1302  break;
1303 
1305  case EXIF_TAG_COMPRESSION:
1306  case EXIF_TAG_LIGHT_SOURCE:
1311  case EXIF_TAG_FLASH:
1313  case EXIF_TAG_COLOR_SPACE:
1314  CF (e,EXIF_FORMAT_SHORT, val, maxlen);
1315  CC (e, 1, val, maxlen);
1316  v_short = exif_get_short (e->data, o);
1317 
1318  /* Search the tag */
1319  for (i = 0; list2[i].tag && (list2[i].tag != e->tag); i++);
1320  if (!list2[i].tag) {
1321  snprintf (val, maxlen, _("Internal error (unknown "
1322  "value %i)"), v_short);
1323  break;
1324  }
1325 
1326  /* Find the value */
1327  for (j = 0; list2[i].elem[j].values[0] &&
1328  (list2[i].elem[j].index < v_short); j++);
1329  if (list2[i].elem[j].index != v_short) {
1330  snprintf (val, maxlen, _("Internal error (unknown "
1331  "value %i)"), v_short);
1332  break;
1333  }
1334 
1335  /* Find a short enough value */
1336  memset (val, 0, maxlen);
1337  for (k = 0; list2[i].elem[j].values[k]; k++) {
1338  size_t l = strlen (_(list2[i].elem[j].values[k]));
1339  if ((maxlen > l) && (strlen (val) < l))
1340  strncpy (val, _(list2[i].elem[j].values[k]), maxlen-1);
1341  }
1342  if (!val[0]) snprintf (val, maxlen, "%i", v_short);
1343 
1344  break;
1345 
1348  case EXIF_TAG_ORIENTATION:
1355  case EXIF_TAG_GAIN_CONTROL:
1356  case EXIF_TAG_SATURATION:
1357  case EXIF_TAG_CONTRAST:
1358  case EXIF_TAG_SHARPNESS:
1359  CF (e, EXIF_FORMAT_SHORT, val, maxlen);
1360  CC (e, 1, val, maxlen);
1361  v_short = exif_get_short (e->data, o);
1362 
1363  /* Search the tag */
1364  for (i = 0; list[i].tag && (list[i].tag != e->tag); i++);
1365  if (!list[i].tag) {
1366  snprintf (val, maxlen, _("Internal error (unknown "
1367  "value %i)"), v_short);
1368  break;
1369  }
1370 
1371  /* Find the value */
1372  for (j = 0; list[i].strings[j] && (j < v_short); j++);
1373  if (!list[i].strings[j])
1374  snprintf (val, maxlen, "%i", v_short);
1375  else if (!*list[i].strings[j])
1376  snprintf (val, maxlen, _("Unknown value %i"), v_short);
1377  else
1378  strncpy (val, _(list[i].strings[j]), maxlen-1);
1379  break;
1380 
1381  case EXIF_TAG_XP_TITLE:
1382  case EXIF_TAG_XP_COMMENT:
1383  case EXIF_TAG_XP_AUTHOR:
1384  case EXIF_TAG_XP_KEYWORDS:
1385  case EXIF_TAG_XP_SUBJECT:
1386  {
1387  unsigned char *utf16;
1388 
1389  /* Sanity check the size to prevent overflow. Note EXIF files are 64kb at most. */
1390  if (e->size >= 65536 - sizeof(uint16_t)*2) break;
1391 
1392  /* The tag may not be U+0000-terminated , so make a local
1393  U+0000-terminated copy before converting it */
1394  utf16 = exif_mem_alloc (e->priv->mem, e->size+sizeof(uint16_t)+1);
1395  if (!utf16) break;
1396  memcpy(utf16, e->data, e->size);
1397 
1398  /* NUL terminate the string. If the size is odd (which isn't possible
1399  * for a valid UTF16 string), then this will overwrite the high byte of
1400  * the final half word, plus add a full zero NUL word at the end.
1401  */
1402  utf16[e->size] = 0;
1403  utf16[e->size+1] = 0;
1404  utf16[e->size+2] = 0;
1405 
1406  /* Warning! The texts are converted from UTF16 to UTF8 */
1407  /* FIXME: use iconv to convert into the locale encoding */
1408  exif_convert_utf16_to_utf8(val, utf16, maxlen);
1409  exif_mem_free(e->priv->mem, utf16);
1410  break;
1411  }
1412 
1413  default:
1414  /* Use a generic value formatting */
1415  exif_entry_format_value(e, val, maxlen);
1416  }
1417 
1418  return val;
1419 }
1420 
1421 static
1424 
1425  if(!info) {
1426  e->components = 0;
1428  e->size = 0;
1429  e->data = NULL;
1430  return;
1431  }
1432 
1433  e->format = info->format;
1434  e->components = info->components;
1435 
1436  if(info->components == 0) {
1437  /* No pre-allocation */
1438  e->size = 0;
1439  e->data = NULL;
1440  } else {
1441  int hasDefault = (info->default_size && info->default_value);
1442  int allocSize = hasDefault ? info->default_size : (exif_format_get_size (e->format) * e->components);
1443  e->size = allocSize;
1444  e->data = exif_entry_alloc (e, e->size);
1445  if(!e->data) {
1446  clear_entry(e);
1447  return;
1448  }
1449  if(hasDefault) {
1450  memcpy(e->data, info->default_value, info->default_size);
1451  }
1452  }
1453 }
1454 
1458 void
1460 {
1461  ExifRational r;
1462  ExifByteOrder o;
1463 
1464  /* We need the byte order */
1465  if (!e || !e->parent || e->data || !e->parent->parent)
1466  return;
1468 
1469  e->tag = tag;
1470 
1471  if(exif_entry_get_ifd(e) == EXIF_IFD_GPS) {
1473  return;
1474  }
1475 
1476  switch (tag) {
1477 
1478  /* LONG, 1 component, no default */
1486  e->components = 1;
1487  e->format = EXIF_FORMAT_LONG;
1488  e->size = exif_format_get_size (e->format) * e->components;
1489  e->data = exif_entry_alloc (e, e->size);
1490  if (!e->data) { clear_entry(e); break; }
1491  break;
1492 
1493  /* SHORT, 1 component, no default */
1497  case EXIF_TAG_COMPRESSION:
1501  case EXIF_TAG_GAIN_CONTROL:
1503  case EXIF_TAG_FLASH:
1506 
1507  /* SHORT, 1 component, default 0 */
1508  case EXIF_TAG_IMAGE_WIDTH:
1509  case EXIF_TAG_IMAGE_LENGTH:
1511  case EXIF_TAG_LIGHT_SOURCE:
1515  case EXIF_TAG_CONTRAST:
1516  case EXIF_TAG_SATURATION:
1517  case EXIF_TAG_SHARPNESS:
1518  e->components = 1;
1520  e->size = exif_format_get_size (e->format) * e->components;
1521  e->data = exif_entry_alloc (e, e->size);
1522  if (!e->data) { clear_entry(e); break; }
1523  exif_set_short (e->data, o, 0);
1524  break;
1525 
1526  /* SHORT, 1 component, default 1 */
1527  case EXIF_TAG_ORIENTATION:
1530  e->components = 1;
1532  e->size = exif_format_get_size (e->format) * e->components;
1533  e->data = exif_entry_alloc (e, e->size);
1534  if (!e->data) { clear_entry(e); break; }
1535  exif_set_short (e->data, o, 1);
1536  break;
1537 
1538  /* SHORT, 1 component, default 2 */
1541  e->components = 1;
1543  e->size = exif_format_get_size (e->format) * e->components;
1544  e->data = exif_entry_alloc (e, e->size);
1545  if (!e->data) { clear_entry(e); break; }
1546  exif_set_short (e->data, o, 2);
1547  break;
1548 
1549  /* SHORT, 1 component, default 3 */
1551  e->components = 1;
1553  e->size = exif_format_get_size (e->format) * e->components;
1554  e->data = exif_entry_alloc (e, e->size);
1555  if (!e->data) { clear_entry(e); break; }
1556  exif_set_short (e->data, o, 3);
1557  break;
1558 
1559  /* SHORT, 1 component, default 0xffff */
1560  case EXIF_TAG_COLOR_SPACE:
1561  e->components = 1;
1563  e->size = exif_format_get_size (e->format) * e->components;
1564  e->data = exif_entry_alloc (e, e->size);
1565  if (!e->data) { clear_entry(e); break; }
1566  exif_set_short (e->data, o, 0xffff);
1567  break;
1568 
1569  /* SHORT, 3 components, default 8 8 8 */
1571  e->components = 3;
1573  e->size = exif_format_get_size (e->format) * e->components;
1574  e->data = exif_entry_alloc (e, e->size);
1575  if (!e->data) { clear_entry(e); break; }
1576  exif_set_short (e->data, o, 8);
1577  exif_set_short (
1578  e->data + exif_format_get_size (e->format),
1579  o, 8);
1580  exif_set_short (
1581  e->data + 2 * exif_format_get_size (e->format),
1582  o, 8);
1583  break;
1584 
1585  /* SHORT, 2 components, default 2 1 */
1587  e->components = 2;
1589  e->size = exif_format_get_size (e->format) * e->components;
1590  e->data = exif_entry_alloc (e, e->size);
1591  if (!e->data) { clear_entry(e); break; }
1592  exif_set_short (e->data, o, 2);
1593  exif_set_short (
1594  e->data + exif_format_get_size (e->format),
1595  o, 1);
1596  break;
1597 
1598  /* SRATIONAL, 1 component, no default */
1602  e->components = 1;
1604  e->size = exif_format_get_size (e->format) * e->components;
1605  e->data = exif_entry_alloc (e, e->size);
1606  if (!e->data) { clear_entry(e); break; }
1607  break;
1608 
1609  /* RATIONAL, 1 component, no default */
1614  case EXIF_TAG_FLASH_ENERGY:
1615  case EXIF_TAG_FNUMBER:
1616  case EXIF_TAG_FOCAL_LENGTH:
1623  e->components = 1;
1625  e->size = exif_format_get_size (e->format) * e->components;
1626  e->data = exif_entry_alloc (e, e->size);
1627  if (!e->data) { clear_entry(e); break; }
1628  break;
1629 
1630  /* RATIONAL, 1 component, default 72/1 */
1631  case EXIF_TAG_X_RESOLUTION:
1632  case EXIF_TAG_Y_RESOLUTION:
1633  e->components = 1;
1635  e->size = exif_format_get_size (e->format) * e->components;
1636  e->data = exif_entry_alloc (e, e->size);
1637  if (!e->data) { clear_entry(e); break; }
1638  r.numerator = 72;
1639  r.denominator = 1;
1640  exif_set_rational (e->data, o, r);
1641  break;
1642 
1643  /* RATIONAL, 2 components, no default */
1644  case EXIF_TAG_WHITE_POINT:
1645  e->components = 2;
1647  e->size = exif_format_get_size (e->format) * e->components;
1648  e->data = exif_entry_alloc (e, e->size);
1649  if (!e->data) { clear_entry(e); break; }
1650  break;
1651 
1652  /* RATIONAL, 6 components */
1654  e->components = 6;
1656  e->size = exif_format_get_size (e->format) * e->components;
1657  e->data = exif_entry_alloc (e, e->size);
1658  if (!e->data) { clear_entry(e); break; }
1659  r.denominator = 1;
1660  r.numerator = 0;
1661  exif_set_rational (e->data, o, r);
1662  r.numerator = 255;
1664  e->data + exif_format_get_size (e->format), o, r);
1665  r.numerator = 0;
1667  e->data + 2 * exif_format_get_size (e->format), o, r);
1668  r.numerator = 255;
1670  e->data + 3 * exif_format_get_size (e->format), o, r);
1671  r.numerator = 0;
1673  e->data + 4 * exif_format_get_size (e->format), o, r);
1674  r.numerator = 255;
1676  e->data + 5 * exif_format_get_size (e->format), o, r);
1677  break;
1678 
1679  /* ASCII, 20 components */
1680  case EXIF_TAG_DATE_TIME:
1683  {
1684  time_t t;
1685 #if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S)
1686  struct tm tms;
1687 #endif
1688  struct tm *tm;
1689 
1690  t = time (NULL);
1691 #ifdef HAVE_LOCALTIME_R
1692  tm = localtime_r (&t, &tms);
1693 #elif defined(HAVE_LOCALTIME_S)
1694  localtime_s (&tms, &t);
1695  tm = &tms;
1696 #else
1697  tm = localtime (&t);
1698 #endif
1699  e->components = 20;
1701  e->size = exif_format_get_size (e->format) * e->components;
1702  e->data = exif_entry_alloc (e, e->size);
1703  if (!e->data) { clear_entry(e); break; }
1704  snprintf ((char *) e->data, e->size,
1705  "%04i:%02i:%02i %02i:%02i:%02i",
1706  tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
1707  tm->tm_hour, tm->tm_min, tm->tm_sec);
1708  break;
1709  }
1710 
1711  /* ASCII, no default */
1712  case EXIF_TAG_SUB_SEC_TIME:
1715  e->components = 0;
1717  e->size = 0;
1718  e->data = NULL;
1719  break;
1720 
1721  /* ASCII, default "[None]" */
1723  case EXIF_TAG_MAKE:
1724  case EXIF_TAG_MODEL:
1725  case EXIF_TAG_SOFTWARE:
1726  case EXIF_TAG_ARTIST:
1727  e->components = strlen (_("[None]")) + 1;
1729  e->size = exif_format_get_size (e->format) * e->components;
1730  e->data = exif_entry_alloc (e, e->size);
1731  if (!e->data) { clear_entry(e); break; }
1732  strncpy ((char *)e->data, _("[None]"), e->size);
1733  break;
1734  /* ASCII, default "[None]\0[None]\0" */
1735  case EXIF_TAG_COPYRIGHT:
1736  e->components = (strlen (_("[None]")) + 1) * 2;
1738  e->size = exif_format_get_size (e->format) * e->components;
1739  e->data = exif_entry_alloc (e, e->size);
1740  if (!e->data) { clear_entry(e); break; }
1741  strcpy (((char *)e->data) + 0, _("[None]"));
1742  strcpy (((char *)e->data) + strlen (_("[None]")) + 1, _("[None]"));
1743  break;
1744 
1745  /* UNDEFINED, 1 component, default 1 */
1746  case EXIF_TAG_SCENE_TYPE:
1747  e->components = 1;
1749  e->size = exif_format_get_size (e->format) * e->components;
1750  e->data = exif_entry_alloc (e, e->size);
1751  if (!e->data) { clear_entry(e); break; }
1752  e->data[0] = 0x01;
1753  break;
1754 
1755  /* UNDEFINED, 1 component, default 3 */
1756  case EXIF_TAG_FILE_SOURCE:
1757  e->components = 1;
1759  e->size = exif_format_get_size (e->format) * e->components;
1760  e->data = exif_entry_alloc (e, e->size);
1761  if (!e->data) { clear_entry(e); break; }
1762  e->data[0] = 0x03;
1763  break;
1764 
1765  /* UNDEFINED, 4 components, default 48 49 48 48 */
1767  e->components = 4;
1769  e->size = exif_format_get_size (e->format) * e->components;
1770  e->data = exif_entry_alloc (e, e->size);
1771  if (!e->data) { clear_entry(e); break; }
1772  memcpy (e->data, "0100", 4);
1773  break;
1774 
1775  /* UNDEFINED, 4 components, default 48 50 49 48 */
1776  case EXIF_TAG_EXIF_VERSION:
1777  e->components = 4;
1779  e->size = exif_format_get_size (e->format) * e->components;
1780  e->data = exif_entry_alloc (e, e->size);
1781  if (!e->data) { clear_entry(e); break; }
1782  memcpy (e->data, "0210", 4);
1783  break;
1784 
1785  /* UNDEFINED, 4 components, default 1 2 3 0 */
1787  e->components = 4;
1789  e->size = exif_format_get_size (e->format) * e->components;
1790  e->data = exif_entry_alloc (e, e->size);
1791  if (!e->data) { clear_entry(e); break; }
1792  e->data[0] = 1;
1793  e->data[1] = 2;
1794  e->data[2] = 3;
1795  e->data[3] = 0;
1796  break;
1797 
1798  /* UNDEFINED, no components, no default */
1799  /* Use this if the tag is otherwise unsupported */
1800  case EXIF_TAG_MAKER_NOTE:
1801  case EXIF_TAG_USER_COMMENT:
1802  default:
1803  e->components = 0;
1805  e->size = 0;
1806  e->data = NULL;
1807  break;
1808  }
1809 }
ExifByteOrder
Which byte order to use.
ExifEntry * exif_content_get_entry(ExifContent *content, ExifTag tag)
Return the ExifEntry in this IFD corresponding to the given tag.
Definition: exif-content.c:202
ExifByteOrder exif_data_get_byte_order(ExifData *data)
Return the byte order in use by this EXIF structure.
Definition: exif-data.c:1173
static void clear_entry(ExifEntry *e)
Definition: exif-entry.c:172
static const struct @4 list[]
void exif_entry_free(ExifEntry *e)
Actually free the ExifEntry.
Definition: exif-entry.c:157
const char * values[4]
list of progressively shorter string descriptions; the longest one that fits will be selected
Definition: exif-entry.c:714
#define CC(entry, target, v, maxlen)
Definition: exif-entry.c:657
const char * strings[10]
Definition: exif-entry.c:671
ExifEntry * exif_entry_new_mem(ExifMem *mem)
Reserve memory for and initialize new ExifEntry using the specified memory allocator.
Definition: exif-entry.c:122
ExifShort index
Definition: exif-entry.c:713
ExifTag tag
Definition: exif-entry.c:670
ExifEntry * exif_entry_new(void)
Reserve memory for and initialize a new ExifEntry.
Definition: exif-entry.c:111
void exif_entry_unref(ExifEntry *e)
Decrease reference counter for ExifEntry.
Definition: exif-entry.c:147
#define CF(entry, target, v, maxlen)
Definition: exif-entry.c:644
static const struct @5 list2[]
static void * exif_entry_alloc(ExifEntry *e, unsigned int i)
Definition: exif-entry.c:75
void exif_entry_fix(ExifEntry *e)
Fix the type or format of the given EXIF entry to bring it into spec.
Definition: exif-entry.c:205
struct @5::@6 elem[25]
static void * exif_entry_realloc(ExifEntry *e, void *d_orig, unsigned int i)
Definition: exif-entry.c:92
static void exif_entry_log(ExifEntry *e, ExifLogCode code, const char *format,...)
Definition: exif-entry.c:53
static int match_repeated_char(const unsigned char *data, unsigned char ch, size_t n)
Check if a string consists entirely of a single, repeated character.
Definition: exif-entry.c:630
ExifLog * exif_data_get_log(ExifData *)
Definition: exif-data.c:1250
void exif_entry_initialize(ExifEntry *e, ExifTag tag)
Initialize an empty ExifEntry with default data in the correct format for the given tag.
Definition: exif-entry.c:1459
void exif_entry_dump(ExifEntry *e, unsigned int indent)
Dump text representation of ExifEntry to stdout.
Definition: exif-entry.c:598
static void exif_entry_format_value(ExifEntry *e, char *val, size_t maxlen)
Format the value of an ExifEntry for human display in a generic way.
Definition: exif-entry.c:451
#define M_PI
Definition: exif-entry.c:38
static void exif_entry_initialize_gps(ExifEntry *e, ExifTag tag)
Definition: exif-entry.c:1422
void exif_entry_ref(ExifEntry *e)
Increase reference counter for ExifEntry.
Definition: exif-entry.c:139
const char * exif_entry_get_value(ExifEntry *e, char *val, unsigned int maxlen)
Return a localized textual representation of the value of the EXIF entry.
Definition: exif-entry.c:846
static ExifShort exif_get_short_convert(const unsigned char *buf, ExifFormat format, ExifByteOrder order)
Get a value and convert it to an ExifShort.
Definition: exif-entry.c:183
Handling EXIF entries.
#define exif_entry_get_ifd(e)
Return the IFD number of the given ExifEntry.
Definition: exif-entry.h:180
const char * exif_format_get_name(ExifFormat format)
Return a textual representation of the given EXIF data type.
Definition: exif-format.c:53
unsigned char exif_format_get_size(ExifFormat format)
Return the raw size of the given EXIF data type.
Definition: exif-format.c:66
ExifFormat format
Definition: exif-format.c:33
ExifFormat
EXIF tag data formats.
Definition: exif-format.h:32
@ EXIF_FORMAT_SLONG
Definition: exif-format.h:41
@ EXIF_FORMAT_RATIONAL
Definition: exif-format.h:37
@ EXIF_FORMAT_SRATIONAL
Definition: exif-format.h:42
@ EXIF_FORMAT_LONG
Definition: exif-format.h:36
@ EXIF_FORMAT_UNDEFINED
Definition: exif-format.h:39
@ EXIF_FORMAT_SHORT
Definition: exif-format.h:35
@ EXIF_FORMAT_SSHORT
Definition: exif-format.h:40
@ EXIF_FORMAT_ASCII
Definition: exif-format.h:34
@ EXIF_FORMAT_SBYTE
Definition: exif-format.h:38
@ EXIF_FORMAT_FLOAT
Definition: exif-format.h:43
@ EXIF_FORMAT_DOUBLE
Definition: exif-format.h:44
@ EXIF_FORMAT_BYTE
Definition: exif-format.h:33
const ExifGPSIfdTagInfo * exif_get_gps_tag_info(ExifTag tag)
Definition: exif-gps-ifd.c:61
Info about GPS tags.
@ EXIF_IFD_GPS
Definition: exif-ifd.h:33
@ EXIF_IFD_0
Definition: exif-ifd.h:30
ExifLogCode code
Definition: exif-log.c:39
void exif_logv(ExifLog *log, ExifLogCode code, const char *domain, const char *format, va_list args)
Definition: exif-log.c:146
ExifLogCode
Definition: exif-log.h:54
@ EXIF_LOG_CODE_NO_MEMORY
Definition: exif-log.h:57
@ EXIF_LOG_CODE_CORRUPT_DATA
Definition: exif-log.h:58
@ EXIF_LOG_CODE_DEBUG
Definition: exif-log.h:56
#define EXIF_LOG_NO_MEMORY(l, d, s)
Definition: exif-log.h:110
void * exif_mem_realloc(ExifMem *mem, void *d, ExifLong ds)
Definition: exif-mem.c:89
void exif_mem_free(ExifMem *mem, void *d)
Definition: exif-mem.c:69
void exif_mem_unref(ExifMem *mem)
Unrefcount an ExifMem.
Definition: exif-mem.c:61
ExifMem * exif_mem_new_default(void)
Create a new ExifMem with default values for your convenience.
Definition: exif-mem.c:95
void * exif_mem_alloc(ExifMem *mem, ExifLong ds)
Definition: exif-mem.c:79
void exif_mem_ref(ExifMem *mem)
Refcount an ExifMem.
Definition: exif-mem.c:54
const char * exif_tag_get_name_in_ifd(ExifTag tag, ExifIfd ifd)
Return a textual name of the given tag when found in the given IFD.
Definition: exif-tag.c:1038
ExifTag
EXIF tags.
Definition: exif-tag.h:34
@ EXIF_TAG_XP_SUBJECT
Definition: exif-tag.h:128
@ EXIF_TAG_DATE_TIME_ORIGINAL
Definition: exif-tag.h:100
@ EXIF_TAG_FNUMBER
Definition: exif-tag.h:82
@ EXIF_TAG_COLOR_SPACE
Definition: exif-tag.h:130
@ EXIF_TAG_SUBJECT_LOCATION
Definition: exif-tag.h:140
@ EXIF_TAG_ISO_SPEED_RATINGS
Definition: exif-tag.h:90
@ EXIF_TAG_SUB_SEC_TIME
Definition: exif-tag.h:121
@ EXIF_TAG_ORIENTATION
Definition: exif-tag.h:49
@ EXIF_TAG_GAIN_CONTROL
Definition: exif-tag.h:152
@ EXIF_TAG_EXIF_IFD_POINTER
Definition: exif-tag.h:85
@ EXIF_TAG_INTEROPERABILITY_VERSION
Definition: exif-tag.h:36
@ EXIF_TAG_EXIF_VERSION
Definition: exif-tag.h:99
@ EXIF_TAG_XP_TITLE
Definition: exif-tag.h:124
@ EXIF_TAG_EXPOSURE_MODE
Definition: exif-tag.h:147
@ EXIF_TAG_XP_KEYWORDS
Definition: exif-tag.h:127
@ EXIF_TAG_FLASH_ENERGY
Definition: exif-tag.h:135
@ EXIF_TAG_EXPOSURE_TIME
Definition: exif-tag.h:81
@ EXIF_TAG_DATE_TIME
Definition: exif-tag.h:59
@ EXIF_TAG_MAX_APERTURE_VALUE
Definition: exif-tag.h:111
@ EXIF_TAG_FLASH
Definition: exif-tag.h:115
@ EXIF_TAG_PLANAR_CONFIGURATION
Definition: exif-tag.h:55
@ EXIF_TAG_RESOLUTION_UNIT
Definition: exif-tag.h:56
@ EXIF_TAG_COMPRESSION
Definition: exif-tag.h:41
@ EXIF_TAG_MODEL
Definition: exif-tag.h:47
@ EXIF_TAG_BITS_PER_SAMPLE
Definition: exif-tag.h:40
@ EXIF_TAG_SUBJECT_DISTANCE
Definition: exif-tag.h:112
@ EXIF_TAG_IMAGE_WIDTH
Definition: exif-tag.h:38
@ EXIF_TAG_USER_COMMENT
Definition: exif-tag.h:120
@ EXIF_TAG_GPS_INFO_IFD_POINTER
Definition: exif-tag.h:89
@ EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT
Definition: exif-tag.h:139
@ EXIF_TAG_APERTURE_VALUE
Definition: exif-tag.h:108
@ EXIF_TAG_IMAGE_DESCRIPTION
Definition: exif-tag.h:45
@ EXIF_TAG_SOFTWARE
Definition: exif-tag.h:58
@ EXIF_TAG_INTEROPERABILITY_IFD_POINTER
Definition: exif-tag.h:134
@ EXIF_TAG_FLASH_PIX_VERSION
Definition: exif-tag.h:129
@ EXIF_TAG_DIGITAL_ZOOM_RATIO
Definition: exif-tag.h:149
@ EXIF_TAG_Y_RESOLUTION
Definition: exif-tag.h:54
@ EXIF_TAG_JPEG_INTERCHANGE_FORMAT
Definition: exif-tag.h:66
@ EXIF_TAG_FILE_SOURCE
Definition: exif-tag.h:143
@ EXIF_TAG_SCENE_TYPE
Definition: exif-tag.h:144
@ EXIF_TAG_ARTIST
Definition: exif-tag.h:60
@ EXIF_TAG_COPYRIGHT
Definition: exif-tag.h:80
@ EXIF_TAG_COMPONENTS_CONFIGURATION
Definition: exif-tag.h:105
@ EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH
Definition: exif-tag.h:67
@ EXIF_TAG_SHUTTER_SPEED_VALUE
Definition: exif-tag.h:107
@ EXIF_TAG_PIXEL_Y_DIMENSION
Definition: exif-tag.h:132
@ EXIF_TAG_PIXEL_X_DIMENSION
Definition: exif-tag.h:131
@ EXIF_TAG_MAKE
Definition: exif-tag.h:46
@ EXIF_TAG_YCBCR_POSITIONING
Definition: exif-tag.h:70
@ EXIF_TAG_EXPOSURE_PROGRAM
Definition: exif-tag.h:87
@ EXIF_TAG_PHOTOMETRIC_INTERPRETATION
Definition: exif-tag.h:42
@ EXIF_TAG_EXPOSURE_INDEX
Definition: exif-tag.h:141
@ EXIF_TAG_LIGHT_SOURCE
Definition: exif-tag.h:114
@ EXIF_TAG_YCBCR_SUB_SAMPLING
Definition: exif-tag.h:69
@ EXIF_TAG_CONTRAST
Definition: exif-tag.h:153
@ EXIF_TAG_SCENE_CAPTURE_TYPE
Definition: exif-tag.h:151
@ EXIF_TAG_SAMPLES_PER_PIXEL
Definition: exif-tag.h:50
@ EXIF_TAG_EXPOSURE_BIAS_VALUE
Definition: exif-tag.h:110
@ EXIF_TAG_WHITE_BALANCE
Definition: exif-tag.h:148
@ EXIF_TAG_SENSITIVITY_TYPE
Definition: exif-tag.h:93
@ EXIF_TAG_SATURATION
Definition: exif-tag.h:154
@ EXIF_TAG_SUBJECT_DISTANCE_RANGE
Definition: exif-tag.h:157
@ EXIF_TAG_CUSTOM_RENDERED
Definition: exif-tag.h:146
@ EXIF_TAG_REFERENCE_BLACK_WHITE
Definition: exif-tag.h:71
@ EXIF_TAG_DATE_TIME_DIGITIZED
Definition: exif-tag.h:101
@ EXIF_TAG_MAKER_NOTE
Definition: exif-tag.h:119
@ EXIF_TAG_FOCAL_LENGTH
Definition: exif-tag.h:116
@ EXIF_TAG_BRIGHTNESS_VALUE
Definition: exif-tag.h:109
@ EXIF_TAG_SENSING_METHOD
Definition: exif-tag.h:142
@ EXIF_TAG_SUB_SEC_TIME_DIGITIZED
Definition: exif-tag.h:123
@ EXIF_TAG_IMAGE_LENGTH
Definition: exif-tag.h:39
@ EXIF_TAG_SUBJECT_AREA
Definition: exif-tag.h:117
@ EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM
Definition: exif-tag.h:150
@ EXIF_TAG_FOCAL_PLANE_X_RESOLUTION
Definition: exif-tag.h:137
@ EXIF_TAG_X_RESOLUTION
Definition: exif-tag.h:53
@ EXIF_TAG_COMPRESSED_BITS_PER_PIXEL
Definition: exif-tag.h:106
@ EXIF_TAG_SUB_SEC_TIME_ORIGINAL
Definition: exif-tag.h:122
@ EXIF_TAG_PRIMARY_CHROMATICITIES
Definition: exif-tag.h:62
@ EXIF_TAG_FOCAL_PLANE_Y_RESOLUTION
Definition: exif-tag.h:138
@ EXIF_TAG_WHITE_POINT
Definition: exif-tag.h:61
@ EXIF_TAG_XP_COMMENT
Definition: exif-tag.h:125
@ EXIF_TAG_METERING_MODE
Definition: exif-tag.h:113
@ EXIF_TAG_XP_AUTHOR
Definition: exif-tag.h:126
@ EXIF_TAG_SHARPNESS
Definition: exif-tag.h:155
#define EXIF_TAG_GPS_TIME_STAMP
Definition: exif-tag.h:181
#define EXIF_TAG_GPS_VERSION_ID
Definition: exif-tag.h:174
#define EXIF_TAG_GPS_ALTITUDE_REF
Definition: exif-tag.h:179
ExifRational exif_get_rational(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifRational value from memory.
Definition: exif-utils.c:188
void exif_set_rational(unsigned char *buf, ExifByteOrder order, ExifRational value)
Store an ExifRational value into memory in EXIF format.
Definition: exif-utils.c:199
ExifLong exif_get_long(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifLong value from memory.
Definition: exif-utils.c:165
ExifShort exif_get_short(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifShort value from memory.
Definition: exif-utils.c:102
ExifSLong exif_get_slong(const unsigned char *b, ExifByteOrder order)
Retrieve an ExifSLong value from memory.
Definition: exif-utils.c:130
ExifSShort exif_get_sshort(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifSShort value from memory.
Definition: exif-utils.c:87
void exif_set_srational(unsigned char *buf, ExifByteOrder order, ExifSRational value)
Store an ExifSRational value into memory in EXIF format.
Definition: exif-utils.c:208
void exif_set_short(unsigned char *b, ExifByteOrder order, ExifShort value)
Store an ExifShort value into memory in EXIF format.
Definition: exif-utils.c:124
ExifSRational exif_get_srational(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifSRational value from memory.
Definition: exif-utils.c:177
void exif_convert_utf16_to_utf8(char *out, const unsigned char *in, int maxlen)
This function converts rather UCS-2LE than UTF-16 to UTF-8.
Definition: exif-utils.c:220
EXIF data manipulation functions and types.
unsigned char ExifByte
EXIF Unsigned Byte data type.
Definition: exif-utils.h:39
uint32_t ExifLong
EXIF Unsigned Long data type.
Definition: exif-utils.h:54
int32_t ExifSLong
EXIF Signed Long data type.
Definition: exif-utils.h:57
uint16_t ExifShort
EXIF Unsigned Short data type.
Definition: exif-utils.h:48
#define MIN(a, b)
Definition: exif-utils.h:180
int16_t ExifSShort
EXIF Signed Short data type.
Definition: exif-utils.h:51
#define _(String)
Definition: i18n.h:48
#define N_(String)
Definition: i18n.h:49
#define bindtextdomain(Domain, Directory)
Definition: i18n.h:46
uint16_t components
Definition: exif-gps-ifd.h:43
ExifFormat format
Definition: exif-gps-ifd.h:40
const char * default_value
Definition: exif-gps-ifd.h:49
uint16_t default_size
Definition: exif-gps-ifd.h:46
EXIF Unsigned Rational data type.
Definition: exif-utils.h:60
ExifLong denominator
Definition: exif-utils.h:60
ExifLong numerator
Definition: exif-utils.h:60
EXIF Signed Rational data type.
Definition: exif-utils.h:65
ExifSLong numerator
Definition: exif-utils.h:65
ExifSLong denominator
Definition: exif-utils.h:65
ExifData * parent
Data containing this content.
Definition: exif-content.h:46
Represents the entire EXIF data found in an image.
Definition: exif-data.h:47
ExifContent * ifd[EXIF_IFD_COUNT]
Data for each IFD.
Definition: exif-data.h:49
ExifMem * mem
Definition: exif-entry.c:45
unsigned int ref_count
Definition: exif-entry.c:43
Data found in one EXIF tag.
Definition: exif-entry.h:43
unsigned long components
Number of elements in the array, if this is an array entry.
Definition: exif-entry.h:52
ExifFormat format
Type of data in this entry.
Definition: exif-entry.h:48
ExifContent * parent
ExifContent containing this entry.
Definition: exif-entry.h:65
unsigned char * data
Pointer to the raw EXIF data for this entry.
Definition: exif-entry.h:57
ExifTag tag
EXIF tag for this entry.
Definition: exif-entry.h:45
ExifEntryPrivate * priv
Internal data to be used by libexif itself.
Definition: exif-entry.h:68
unsigned int size
Number of bytes in the buffer at data.
Definition: exif-entry.h:61

libexif Generated by doxygen