diff --git a/README b/README index 737d4fc94474467878babb06ed03ad729b88ba86..97c644c541920c83e98393a26001db1820b752d5 100644 --- a/README +++ b/README @@ -56,6 +56,9 @@ variables instead of editing it. E.g.: CFLAGS='-g -Os' make export DESTDIR=/tmp/feh PREFIX=/usr; make && make install +Builtin EXIF support is maintained by Dennis Real, see +<https://github.com/reald/feh>. + Testing (non-X) --------------- diff --git a/src/exif.c b/src/exif.c index 9d26072b6508fbfb9bb4c22b79aa9f21ce98f29d..dcf2a88125d6ef153cfc4bd4a8d608affed6630a 100644 --- a/src/exif.c +++ b/src/exif.c @@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "options.h" #include "debug.h" #include "exif.h" - +#include "exif_nikon.h" /* remove all spaces on the right end of a string */ @@ -140,7 +140,10 @@ ExifData * exif_get_data(char *path) void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize) { ExifEntry *entry = NULL; - char buf[64]; + char buf[128]; + unsigned int exn_fcm = (EXN_FLASH_CONTROL_MODES_MAX-1); /* default to N/A */ + unsigned int version = 0; + unsigned int length = 0; if ( (buffer == NULL) || (maxsize == 0) ) { @@ -151,7 +154,7 @@ void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize) snprintf(buffer, (size_t)maxsize, "%s\n", "No Exif data in file."); return; } - else if ( ed != NULL ) + else { /* normal exif tags */ exif_get_tag(ed, EXIF_IFD_0, EXIF_TAG_MAKE, buffer, maxsize); @@ -185,10 +188,49 @@ void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize) /* Nikon */ if ( strcmp(buf, "Nikon") != 0 ) { - /* Digital Vari-Program */ - exif_get_mnote_tag(ed, 171, buffer + strlen(buffer), maxsize - strlen(buffer)); + /* this is a nikon camera */ + + buf[0] = '\0'; + exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf)); + exif_trim_spaces(buf); + + if ( !(strcmp("Flash: Flash did not fire\n", buf) == 0) ) + { + /* extended flash info if it was fired */ + + /* Flash Setting */ + exif_get_mnote_tag(ed, 8, buffer + strlen(buffer), maxsize - strlen(buffer)); + /* Flash Mode */ + exif_get_mnote_tag(ed, 9, buffer + strlen(buffer), maxsize - strlen(buffer)); + /* flash exposure bracket value */ + exif_get_mnote_tag(ed, 24, buffer + strlen(buffer), maxsize - strlen(buffer)); + /* Flash used */ + exif_get_mnote_tag(ed, 135, buffer + strlen(buffer), maxsize - strlen(buffer)); + + /* Flash info: control mode. */ + /* libexif does not support flash info 168 yet. so we have to parse the debug data :-( */ + buf[0] = '\0'; + exif_get_mnote_tag(ed, 168, buf, sizeof(buf)); + sscanf(buf, "(null): %u bytes unknown data: 303130%02X%*10s%02X", &length, &version, &exn_fcm); + exn_fcm = exn_fcm & EXN_FLASH_CONTROL_MODE_MASK; + + if ( (exn_fcm < EXN_FLASH_CONTROL_MODES_MAX) + && ( ((length == 22) && (version == '3')) /* Nikon FlashInfo0103 */ + || ((length == 22) && (version == '4')) /* Nikon FlashInfo0104 */ + || ((length == 21) && (version == '2')) /* Nikon FlashInfo0102 */ + || ((length == 19) && (version == '0')) /* Nikon FlashInfo0100 */ + ) + ) + { + snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "NikonFlashControlMode: %s\n", + EXN_NikonFlashControlModeValues[exn_fcm]); + } + } /* Lens */ exif_get_mnote_tag(ed, 132, buffer + strlen(buffer), maxsize - strlen(buffer)); + /* Digital Vari-Program */ + exif_get_mnote_tag(ed, 171, buffer + strlen(buffer), maxsize - strlen(buffer)); + } } diff --git a/src/exif_nikon.h b/src/exif_nikon.h new file mode 100644 index 0000000000000000000000000000000000000000..e2baf0deaef83ebe7c046f9d6231c3d73790a03d --- /dev/null +++ b/src/exif_nikon.h @@ -0,0 +1,41 @@ +/* exif_nikon.h + +Copyright (C) 2012 Dennis Real. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies of the Software and its documentation and acknowledgment shall be +given in the documentation and software packages that this Software was +used. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef EXIF_NIKON_H +#define EXIF_NIKON_H + +/* Flash control mode */ +/* http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#FlashControlMode */ +#define EXN_FLASH_CONTROL_MODES_MAX 9 +char *EXN_NikonFlashControlModeValues[EXN_FLASH_CONTROL_MODES_MAX] = {"Off", + "iTTL-BL", "iTTL", "Auto Aperture", + "Automatic", "GN (distance priority)", + "Manual", "Repeating Flash", + "N/A" /* "N/A" is not a nikon setting */ + }; + +#define EXN_FLASH_CONTROL_MODE_MASK 0x7F + +#endif diff --git a/src/list.c b/src/list.c index 3cb9a3d80551bdba84bf778c328de6059eb20f71..17fcbcc5f30b8396a3e070ad7ae3049cebecb9b3 100644 --- a/src/list.c +++ b/src/list.c @@ -44,14 +44,15 @@ void init_list_mode(void) file = FEH_FILE(l->data); if (opt.customlist) printf("%s\n", feh_printf(opt.customlist, file)); - else + else { printf("%d\t%s\t%d\t%d\t%s", ++j, file->info->format, file->info->width, file->info->height, format_size(file->info->pixels)); - printf("\t%s\t\t%c\t%s\n", + printf("\t%s\t%c\t%s\n", format_size(file->info->size), file->info->has_alpha ? 'X' : '-', file->filename); + } feh_action_run(file, opt.actions[0]); } diff --git a/test/feh.t b/test/feh.t index ac9262f1fb79a3a2034e5a9c8e44066a173bb377..34b5cd34e1418fcb8be4b456427403a45338bbd2 100644 --- a/test/feh.t +++ b/test/feh.t @@ -36,7 +36,7 @@ my $re_warning = qr{${feh_name} WARNING: test/fail/... \- No Imlib2 loader for that file format\n}; my $re_loadable = qr{test/ok/...}; my $re_unloadable = qr{test/fail/...}; -my $re_list_action = qr{test/ok/... 16x16 \(${feh_name}\)}; +my $re_list_action = qr{test/ok/... 16x16}; my $cmd = Test::Command->new(cmd => "$feh --version"); @@ -128,7 +128,7 @@ $cmd->stdout_is_file('test/list/default'); $cmd->stderr_is_eq(''); $cmd = Test::Command->new(cmd => - "$feh --quiet --list --action 'echo \"%f %wx%h (%P)\" >&2' $images"); + "$feh --quiet --list --action 'echo \"%f %wx%h\" >&2' $images"); $cmd->exit_is_num(0); $cmd->stdout_is_file('test/list/default'); diff --git a/test/list/default b/test/list/default index d7b2c12b197ca2cad55b2b63116f33494d8a78e1..bc0ef52799d47a9540bc04365386294cb5653a87 100644 --- a/test/list/default +++ b/test/list/default @@ -1,5 +1,5 @@ -NUM FORMAT WIDTH HEIGHT PIXELS SIZE(bytes) ALPHA FILENAME -1 gif 16 16 256 953 - test/ok/gif -2 jpeg 16 16 256 354 - test/ok/jpg -3 png 16 16 256 403 X test/ok/png -4 pnm 16 16 256 269 - test/ok/pnm +NUM FORMAT WIDTH HEIGHT PIXELS SIZE ALPHA FILENAME +1 gif 16 16 256 953 - test/ok/gif +2 jpeg 16 16 256 354 - test/ok/jpg +3 png 16 16 256 403 X test/ok/png +4 pnm 16 16 256 269 - test/ok/pnm diff --git a/test/list/filename_recursive b/test/list/filename_recursive index 5ffa63e98a5c6d518582d23005b762a374b37c87..d4d27dd8bc73e2eb77db49491d7c427a2ecdac7b 100644 --- a/test/list/filename_recursive +++ b/test/list/filename_recursive @@ -1,6 +1,6 @@ -NUM FORMAT WIDTH HEIGHT PIXELS SIZE(bytes) ALPHA FILENAME -1 gif 16 16 256 953 - test/ok/gif -2 jpeg 16 16 256 354 - test/ok/jpg -3 png 16 16 256 403 X test/ok/png -4 pnm 16 16 256 269 - test/ok/pnm -5 png 16 16 256 403 X test/ok/recursive/png +NUM FORMAT WIDTH HEIGHT PIXELS SIZE ALPHA FILENAME +1 gif 16 16 256 953 - test/ok/gif +2 jpeg 16 16 256 354 - test/ok/jpg +3 png 16 16 256 403 X test/ok/png +4 pnm 16 16 256 269 - test/ok/pnm +5 png 16 16 256 403 X test/ok/recursive/png diff --git a/test/list/format_reverse b/test/list/format_reverse index 801b7328a075ae1b84f289ce2e76367eaf80cb7d..9216184c5c5bcc45f7509f9680e4b7d9dbac1f81 100644 --- a/test/list/format_reverse +++ b/test/list/format_reverse @@ -1,5 +1,5 @@ -NUM FORMAT WIDTH HEIGHT PIXELS SIZE(bytes) ALPHA FILENAME -1 pnm 16 16 256 269 - test/ok/pnm -2 png 16 16 256 403 X test/ok/png -3 jpeg 16 16 256 354 - test/ok/jpg -4 gif 16 16 256 953 - test/ok/gif +NUM FORMAT WIDTH HEIGHT PIXELS SIZE ALPHA FILENAME +1 pnm 16 16 256 269 - test/ok/pnm +2 png 16 16 256 403 X test/ok/png +3 jpeg 16 16 256 354 - test/ok/jpg +4 gif 16 16 256 953 - test/ok/gif diff --git a/test/list/size b/test/list/size index 9e1c3d034dc4dd4d665ee4984a37ab0e850df057..cad60b00743dee7d897ef55d85d59e67ad5320aa 100644 --- a/test/list/size +++ b/test/list/size @@ -1,5 +1,5 @@ -NUM FORMAT WIDTH HEIGHT PIXELS SIZE(bytes) ALPHA FILENAME -1 pnm 16 16 256 269 - test/ok/pnm -2 jpeg 16 16 256 354 - test/ok/jpg -3 png 16 16 256 403 X test/ok/png -4 gif 16 16 256 953 - test/ok/gif +NUM FORMAT WIDTH HEIGHT PIXELS SIZE ALPHA FILENAME +1 pnm 16 16 256 269 - test/ok/pnm +2 jpeg 16 16 256 354 - test/ok/jpg +3 png 16 16 256 403 X test/ok/png +4 gif 16 16 256 953 - test/ok/gif