From 48a373c50d2c7f96379602abc1cd1b95bacb1a68 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 13 Jan 2009 00:26:41 -0800 Subject: [PATCH] Added support for Epson MakerNotes, which have the identical tag format and namespace of the Olympus ones. --- ChangeLog | 5 +++++ NEWS | 1 + README | 6 +++--- libexif/exif-data.c | 1 + libexif/olympus/exif-mnote-data-olympus.c | 14 +++++++++++--- libexif/olympus/exif-mnote-data-olympus.h | 9 ++++++++- libexif/olympus/mnote-olympus-entry.c | 23 ++++++++++++++++++----- libexif/olympus/mnote-olympus-tag.c | 5 +++++ libexif/olympus/mnote-olympus-tag.h | 5 +++++ 9 files changed, 57 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68d4048..8a84beb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-01-12 Dan Fandrich + + * Added support for Epson MakerNotes, which have the identical + tag format and namespace of the Olympus ones. + 2009-01-06 Dan Fandrich * libexif/exif-tags.c: Added remaining GPS tags from the EXIF 2.2 diff --git a/NEWS b/NEWS index 91afa40..e82ac56 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ libexif-0.6.x: * Access to the raw EXIF data through the ExifEntry structure members is now officially documented * Fixed some Olympus/Sanyo MakerNote interpretations + * Added support for Epson MakerNotes * Fixed bug #1946138 to stop ignoring CFLAGS in the sqrt configure test * Added remaining GPS tags from the EXIF 2.2 spec to the tag table * Fixed the interpretation of some tags as being optional in IFD 1 diff --git a/README b/README index 3fc03b7..b982c88 100644 --- a/README +++ b/README @@ -13,9 +13,9 @@ FEATURES -------- libexif supports parsing, editing and saving of EXIF data. In addition, it -has gettext support. All EXIF tags described in EXIF standard 2.1 -are supported. Many maker notes from Canon, Casio, Fuji, Nikon, Olympus, -Pentax and Sanyo cameras are also supported. +has gettext support. All EXIF tags described in EXIF standard 2.1 (and most +from 2.2) are supported. Many maker notes from Canon, Casio, Epson, +Fuji, Nikon, Olympus, Pentax and Sanyo cameras are also supported. REQUIREMENTS diff --git a/libexif/exif-data.c b/libexif/exif-data.c index 1185c61..80df646 100644 --- a/libexif/exif-data.c +++ b/libexif/exif-data.c @@ -735,6 +735,7 @@ exif_data_get_type_maker_note (ExifData *d) if ((e->size >= 8) && ( !memcmp (e->data, "OLYMP", 6) || !memcmp (e->data, "OLYMPUS", 8) || !memcmp (e->data, "SANYO", 6) || + !memcmp (e->data, "EPSON", 6) || !memcmp (e->data, "Nikon", 6))) return EXIF_DATA_TYPE_MAKER_NOTE_OLYMPUS; diff --git a/libexif/olympus/exif-mnote-data-olympus.c b/libexif/olympus/exif-mnote-data-olympus.c index 1045738..8b8322c 100644 --- a/libexif/olympus/exif-mnote-data-olympus.c +++ b/libexif/olympus/exif-mnote-data-olympus.c @@ -102,11 +102,13 @@ exif_mnote_data_olympus_save (ExifMnoteData *ne, switch (n->version) { case olympusV1: case sanyoV1: + case epsonV1: *buf = exif_mem_alloc (ne->mem, *buf_size); if (!*buf) return; /* Write the header and the number of entries. */ - strcpy ((char *)*buf, n->version==sanyoV1?"SANYO":"OLYMP"); + strcpy ((char *)*buf, n->version==sanyoV1?"SANYO": + (n->version==epsonV1?"EPSON":"OLYMP")); exif_set_short (*buf + 6, n->order, (ExifShort) 1); datao = n->offset; break; @@ -224,6 +226,9 @@ exif_mnote_data_olympus_load (ExifMnoteData *en, * Sanyo format is identical and uses identical tags except that * header starts with "SANYO". * + * Epson format is identical and uses identical tags except that + * header starts with "EPSON". + * * Nikon headers start with "Nikon" (6 bytes including '\0'), * version number (1 or 2). * @@ -235,13 +240,16 @@ exif_mnote_data_olympus_load (ExifMnoteData *en, * lastly 0x2A. */ if (buf_size - n->offset < 22) return; - if (!memcmp (buf + o2, "OLYMP", 6) || !memcmp (buf + o2, "SANYO", 6)) { + if (!memcmp (buf + o2, "OLYMP", 6) || !memcmp (buf + o2, "SANYO", 6) || + !memcmp (buf + o2, "EPSON", 6)) { exif_log (en->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteDataOlympus", - "Parsing Olympus/Sanyo maker note v1..."); + "Parsing Olympus/Sanyo/Epson maker note v1..."); /* The number of entries is at position 8. */ if (!memcmp (buf + o2, "SANYO", 6)) n->version = sanyoV1; + else if (!memcmp (buf + o2, "EPSON", 6)) + n->version = epsonV1; else n->version = olympusV1; if (buf[o2 + 6] == 1) diff --git a/libexif/olympus/exif-mnote-data-olympus.h b/libexif/olympus/exif-mnote-data-olympus.h index 4d55cab..2d57684 100644 --- a/libexif/olympus/exif-mnote-data-olympus.h +++ b/libexif/olympus/exif-mnote-data-olympus.h @@ -26,7 +26,14 @@ #include #include -enum OlympusVersion {nikonV1 = 1, nikonV2 = 2, olympusV1 = 3, olympusV2 = 4, sanyoV1 = 5 }; +enum OlympusVersion { + nikonV1 = 1, + nikonV2 = 2, + olympusV1 = 3, + olympusV2 = 4, + sanyoV1 = 5, + epsonV1 = 6 +}; typedef struct _ExifMnoteDataOlympus ExifMnoteDataOlympus; diff --git a/libexif/olympus/mnote-olympus-entry.c b/libexif/olympus/mnote-olympus-entry.c index 1281b5d..a3610ec 100644 --- a/libexif/olympus/mnote-olympus-entry.c +++ b/libexif/olympus/mnote-olympus-entry.c @@ -244,6 +244,7 @@ mnote_olympus_entry_get_value (MnoteOlympusEntry *entry, char *v, unsigned int m char buf[30]; ExifLong vl; ExifShort vs = 0; + ExifSShort vss = 0; ExifRational vr, vr2; ExifSRational vsr; int i, j; @@ -305,10 +306,13 @@ mnote_olympus_entry_get_value (MnoteOlympusEntry *entry, char *v, unsigned int m case MNOTE_NIKON_TAG_IMAGEADJUSTMENT: case MNOTE_NIKON_TAG_ADAPTER: case MNOTE_NIKON_TAG_SATURATION2: + case MNOTE_EPSON_TAG_OEM_MODEL: CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen); memcpy(v, entry->data, MIN (maxlen, entry->size)); break; case MNOTE_NIKON_TAG_TOTALPICTURES: + case MNOTE_EPSON_TAG_IMAGE_WIDTH: + case MNOTE_EPSON_TAG_IMAGE_HEIGHT: CF (entry->format, EXIF_FORMAT_LONG, v, maxlen); CC (entry->components, 1, v, maxlen); vl = exif_get_long (entry->data, entry->order); @@ -577,12 +581,21 @@ mnote_olympus_entry_get_value (MnoteOlympusEntry *entry, char *v, unsigned int m } break; case MNOTE_OLYMPUS_TAG_LENSDISTORTION: - CF (entry->format, EXIF_FORMAT_SSHORT, v, maxlen); - CC (entry->components, 6, v, maxlen); - for (i=0; i < (int)entry->components; ++i) { - vs = exif_get_sshort (entry->data+2*i, entry->order); - sprintf (buf, "%hd ", vs); + if (entry->format == EXIF_FORMAT_SHORT) { + /* Epson uses a single SHORT here */ + CC (entry->components, 1, v, maxlen); + vs = exif_get_short (entry->data, entry->order); + sprintf (buf, "%hu", vs); strncat (v, buf, maxlen - strlen (v)); + } else { + /* Others use an array of SSHORT here */ + CC (entry->components, 6, v, maxlen); + CF (entry->format, EXIF_FORMAT_SSHORT, v, maxlen); + for (i=0; i < (int)entry->components; ++i) { + vss = exif_get_sshort (entry->data+2*i, entry->order); + sprintf (buf, "%hd ", vss); + strncat (v, buf, maxlen - strlen (v)); + } } break; case MNOTE_OLYMPUS_TAG_COLORCONTROL: diff --git a/libexif/olympus/mnote-olympus-tag.c b/libexif/olympus/mnote-olympus-tag.c index 37a6bdc..86a71ad 100644 --- a/libexif/olympus/mnote-olympus-tag.c +++ b/libexif/olympus/mnote-olympus-tag.c @@ -182,6 +182,11 @@ static const struct { {MNOTE_SANYO_TAG_SCENESELECT, "SceneSelect", N_("Scene Select"), ""}, {MNOTE_SANYO_TAG_MANUALFOCUSDISTANCE, "ManualFocusDistance", N_("Manual Focus Distance"), ""}, {MNOTE_SANYO_TAG_SEQUENCESHOTINTERVAL, "SequenceShotInterval", N_("Sequence Shot Interval"), ""}, + + /* Epson */ + {MNOTE_EPSON_TAG_IMAGE_WIDTH, "EpsonImageWidth", N_("Epson Image Width"), ""}, + {MNOTE_EPSON_TAG_IMAGE_HEIGHT, "EpsonImageHeight", N_("Epson Image Height"), ""}, + {MNOTE_EPSON_TAG_OEM_MODEL, "EpsonOEMModel", N_("OEM Model Name"), ""}, #endif {0, NULL, NULL, NULL} }; diff --git a/libexif/olympus/mnote-olympus-tag.h b/libexif/olympus/mnote-olympus-tag.h index 0fc485b..16b006b 100644 --- a/libexif/olympus/mnote-olympus-tag.h +++ b/libexif/olympus/mnote-olympus-tag.h @@ -179,6 +179,11 @@ enum _MnoteOlympusTag { MNOTE_SANYO_TAG_SCENESELECT = 0x021f, MNOTE_SANYO_TAG_MANUALFOCUSDISTANCE = 0x0223, MNOTE_SANYO_TAG_SEQUENCESHOTINTERVAL = 0x0224, + + /* Epson */ + MNOTE_EPSON_TAG_IMAGE_WIDTH = 0x020b, + MNOTE_EPSON_TAG_IMAGE_HEIGHT = 0x020c, + MNOTE_EPSON_TAG_OEM_MODEL = 0x020d, }; typedef enum _MnoteOlympusTag MnoteOlympusTag; -- 2.7.4