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

libexif Generated by doxygen