Skip to content
This repository
Browse code

Support for Canon Exif makernote tags

  • Loading branch information...
commit 10b7b1e3e10ba650b240a742947cb6850bbadd23 1 parent 3c284dc
reald reald authored
3  .gitignore
@@ -3,4 +3,5 @@
3 3 /src/*.inc
4 4 /src/feh
5 5 /man/*.1
6   -*~
  6 +*~
  7 +core
23 src/exif.c
@@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 34 #include "options.h"
35 35 #include "debug.h"
36 36 #include "exif.h"
  37 +#include "exif_canon.h"
37 38 #include "exif_nikon.h"
38 39 #include "exif_cfg.h"
39 40
@@ -239,7 +240,7 @@ ExifData * exif_get_data(char *path)
239 240
240 241
241 242
242   -/* get exif data in readable form */
  243 +/* get all exif data in readable form */
243 244 void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize)
244 245 {
245 246 ExifEntry *entry = NULL;
@@ -272,14 +273,12 @@ void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize)
272 273 if (exif_entry_get_value(entry, buf, sizeof(buf)))
273 274 {
274 275 exif_trim_spaces(buf);
275   -
  276 +
276 277 if ( (strcmp(buf, "NIKON CORPORATION") == 0)
277 278 || (strcmp(buf, "Nikon") == 0)
278 279 || (strcmp(buf, "NIKON") == 0)
279 280 )
280 281 {
281   - /* this is a nikon camera */
282   -
283 282 /* show nikon makernote exif tags. list must be defined in exif_cfg.h */
284 283 i=0;
285 284 while ( (Exif_makernote_nikon_tag_list[i] != EXIF_NIKON_MAKERNOTE_END) && (i < USHRT_MAX) )
@@ -290,7 +289,21 @@ void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize)
290 289 }
291 290
292 291 }
293   -
  292 + else if ( (strcmp(buf, "Canon") == 0) )
  293 + {
  294 + /* show canon makernote exif tags. list must be defined in exif_cfg.h */
  295 + i=0;
  296 + while ( (Exif_makernote_canon_tag_list[i] != EXIF_CANON_MAKERNOTE_END) && (i < USHRT_MAX) )
  297 + {
  298 + exc_get_mnote_canon_tags(ed, Exif_makernote_canon_tag_list[i],
  299 + buffer + strlen(buffer), maxsize - strlen(buffer));
  300 + i++;
  301 + }
  302 +
  303 + }
  304 + else
  305 + {
  306 + }
294 307 }
295 308
296 309 }
61 src/exif_canon.c
... ... @@ -0,0 +1,61 @@
  1 +/* exif_canon.c
  2 +
  3 +Copyright (C) 2012 Dennis Real.
  4 +
  5 +Permission is hereby granted, free of charge, to any person obtaining a copy
  6 +of this software and associated documentation files (the "Software"), to
  7 +deal in the Software without restriction, including without limitation the
  8 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9 +sell copies of the Software, and to permit persons to whom the Software is
  10 +furnished to do so, subject to the following conditions:
  11 +
  12 +The above copyright notice and this permission notice shall be included in
  13 +all copies of the Software and its documentation and acknowledgment shall be
  14 +given in the documentation and software packages that this Software was
  15 +used.
  16 +
  17 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20 +THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  21 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23 +
  24 +*/
  25 +
  26 +#ifdef HAVE_LIBEXIF
  27 +
  28 +#include <stdio.h>
  29 +#include <libexif/exif-data.h>
  30 +
  31 +#include "feh.h"
  32 +#include "debug.h"
  33 +#include "exif.h"
  34 +#include "exif_canon.h"
  35 +
  36 +
  37 +
  38 +/* get interesting canon maker note tags in readable form */
  39 +void exc_get_mnote_canon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize)
  40 +{
  41 + /* char buf[EXIF_STD_BUF_LEN];
  42 +
  43 + buf[0] = '\0';
  44 + exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf));
  45 + exif_trim_spaces(buf); */
  46 +
  47 + switch(tag)
  48 + {
  49 + default:
  50 + {
  51 + /* normal makernote tags without special treatment */
  52 + exif_get_mnote_tag(ed, tag, buffer, maxsize);
  53 + }
  54 + break;
  55 + }
  56 +
  57 +
  58 + return;
  59 +}
  60 +
  61 +#endif
33 src/exif_canon.h
... ... @@ -0,0 +1,33 @@
  1 +/* exif_canon.h
  2 +
  3 +Copyright (C) 2012 Dennis Real.
  4 +
  5 +Permission is hereby granted, free of charge, to any person obtaining a copy
  6 +of this software and associated documentation files (the "Software"), to
  7 +deal in the Software without restriction, including without limitation the
  8 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9 +sell copies of the Software, and to permit persons to whom the Software is
  10 +furnished to do so, subject to the following conditions:
  11 +
  12 +The above copyright notice and this permission notice shall be included in
  13 +all copies of the Software and its documentation and acknowledgment shall be
  14 +given in the documentation and software packages that this Software was
  15 +used.
  16 +
  17 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20 +THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  21 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23 +
  24 +*/
  25 +
  26 +#ifndef EXIF_CANON_H
  27 +#define EXIF_CANON_H
  28 +
  29 +#include <libexif/exif-data.h>
  30 +
  31 +extern void exc_get_mnote_canon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize);
  32 +
  33 +#endif
20 src/exif_cfg.h
@@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 30
31 31 typedef struct
32 32 {
33   - ExifIfd ifd; /* section */
  33 + ExifIfd ifd; /* section */
34 34 ExifTag tag; /* tag */
35 35 } t_EXIF_INFO;
36 36
@@ -59,6 +59,9 @@ const t_EXIF_INFO Exif_tag_list [] =
59 59 };
60 60
61 61
  62 +
  63 +/* Nikon */
  64 +
62 65 #define EXIF_NIKON_MAKERNOTE_END 0 /* end marker: if 0 used as a tag we must find something else */
63 66
64 67 /* show these nikon makernote tags */
@@ -78,4 +81,19 @@ const unsigned int Exif_makernote_nikon_tag_list [] =
78 81 EXIF_NIKON_MAKERNOTE_END /* end marker */
79 82 };
80 83
  84 +
  85 +
  86 +/* Canon */
  87 +#define EXIF_CANON_MAKERNOTE_END 0xFFFF /* end marker: if this is used as a tag we must find something else */
  88 +
  89 +/* show these canon makernote tags */
  90 +const unsigned int Exif_makernote_canon_tag_list [] =
  91 +{
  92 + 8, /* Image Number */
  93 + 9, /* Owner Name */
  94 +
  95 + EXIF_CANON_MAKERNOTE_END /* end marker */
  96 +};
  97 +
  98 +
81 99 #endif
23 src/exif_nikon.c
@@ -26,7 +26,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 26 #ifdef HAVE_LIBEXIF
27 27
28 28 #include <stdio.h>
29   -#include <string.h>
30 29 #include <libexif/exif-data.h>
31 30
32 31 #include "feh.h"
@@ -174,7 +173,7 @@ static void exn_get_mnote_nikon_34(ExifData *ed, char * buffer, unsigned int max
174 173
175 174 buf[0] = '\0';
176 175 exif_get_mnote_tag(ed, 34, buf, sizeof(buf));
177   - sscanf(buf, "(null): %u", &data);
  176 + sscanf(buf, "(null): %u", &data); /* not directly supported by libexif yet */
178 177
179 178 switch(data)
180 179 {
@@ -215,8 +214,7 @@ static void exn_get_mnote_nikon_34(ExifData *ed, char * buffer, unsigned int max
215 214
216 215 }
217 216
218   - snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "Active D-Lightning: %s\n",
219   - answer);
  217 + snprintf(buffer, maxsize, "Active D-Lightning: %s\n", answer);
220 218
221 219 }
222 220
@@ -244,8 +242,7 @@ static void exn_get_mnote_nikon_168(ExifData *ed, char * buffer, unsigned int ma
244 242 )
245 243 )
246 244 {
247   - snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "NikonFlashControlMode: %s\n",
248   - EXN_NikonFlashControlModeValues[exn_fcm]);
  245 + snprintf(buffer, maxsize, "NikonFlashControlMode: %s\n", EXN_NikonFlashControlModeValues[exn_fcm]);
249 246 }
250 247
251 248 }
@@ -283,7 +280,7 @@ static void exn_get_mnote_nikon_183(ExifData *ed, char * buffer, unsigned int ma
283 280 if ( (contrastdetectaf != 0) && (afareamode < EXN_AF_AREA_MODE_C_MAX) )
284 281 {
285 282 /* Contrast AF (live view) */
286   - snprintf(buffer + strlen(buffer), maxsize - strlen(buffer),
  283 + snprintf(buffer, maxsize,
287 284 "ContrastDetectAF: %s; AFAreaMode: %s\n",
288 285 EXN_NikonContrastDetectAF[contrastdetectaf],
289 286 EXN_NikonAFAreaModeContr[afareamode]);
@@ -295,7 +292,7 @@ static void exn_get_mnote_nikon_183(ExifData *ed, char * buffer, unsigned int ma
295 292 buf[0] = '\0';
296 293 exn_get_prim_af_pt(phasedetectaf, primaryafpoint, buf, EXIF_STD_BUF_LEN);
297 294
298   - snprintf(buffer + strlen(buffer), maxsize - strlen(buffer),
  295 + snprintf(buffer, maxsize,
299 296 "PhaseDetectAF: %s; AreaMode: %s; PrimaryAFPoint: %s\n",
300 297 EXN_NikonPhaseDetectAF[phasedetectaf],
301 298 EXN_NikonAFAreaModePhase[afareamode],
@@ -328,7 +325,7 @@ void exn_get_mnote_nikon_tags(ExifData *ed, unsigned int tag, char * buffer, uns
328 325 if ( !(strcmp("Flash: Flash did not fire\n", buf) == 0) )
329 326 {
330 327 /* show extended flash info only if flash was fired */
331   - exif_get_mnote_tag(ed, tag, buffer + strlen(buffer), maxsize - strlen(buffer));
  328 + exif_get_mnote_tag(ed, tag, buffer, maxsize);
332 329 }
333 330 }
334 331 break;
@@ -336,7 +333,7 @@ void exn_get_mnote_nikon_tags(ExifData *ed, unsigned int tag, char * buffer, uns
336 333 case 34:
337 334 {
338 335 /* ActiveD-Lighting */
339   - exn_get_mnote_nikon_34(ed, buffer + strlen(buffer), maxsize - strlen(buffer));
  336 + exn_get_mnote_nikon_34(ed, buffer, maxsize);
340 337 }
341 338 break;
342 339
@@ -346,7 +343,7 @@ void exn_get_mnote_nikon_tags(ExifData *ed, unsigned int tag, char * buffer, uns
346 343 if ( !(strcmp("Flash: Flash did not fire\n", buf) == 0) )
347 344 {
348 345 /* show extended flash info only if flash was fired */
349   - exn_get_mnote_nikon_168(ed, buffer + strlen(buffer), maxsize - strlen(buffer));
  346 + exn_get_mnote_nikon_168(ed, buffer, maxsize);
350 347 }
351 348 }
352 349 break;
@@ -354,14 +351,14 @@ void exn_get_mnote_nikon_tags(ExifData *ed, unsigned int tag, char * buffer, uns
354 351 case 183:
355 352 {
356 353 /* AFInfo 2 */
357   - exn_get_mnote_nikon_183(ed, buffer + strlen(buffer), maxsize - strlen(buffer));
  354 + exn_get_mnote_nikon_183(ed, buffer, maxsize);
358 355 }
359 356 break;
360 357
361 358 default:
362 359 {
363 360 /* normal makernote tags without special treatment */
364   - exif_get_mnote_tag(ed, tag, buffer + strlen(buffer), maxsize - strlen(buffer));
  361 + exif_get_mnote_tag(ed, tag, buffer, maxsize);
365 362 }
366 363 break;
367 364 }

0 comments on commit 10b7b1e

Please sign in to comment.
Something went wrong with that request. Please try again.