Skip to content

Commit

Permalink
Merge pull request #559 from hfiguiere/get-exif
Browse files Browse the repository at this point in the history
gphoto2: added Exif download to CLI and shell
  • Loading branch information
msmeissn authored Jan 13, 2023
2 parents 6d23c4e + 46a925f commit 7635be2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
17 changes: 17 additions & 0 deletions doc/gphoto2.1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ gphoto2 \- command\-line gphoto2 client
.br
[\-\-get\-audio\-data\ \fIRANGE\ or\ NAME\fR] [\-\-get\-all\-audio\-data]
.br
[\-\-get\-exif\ \fIRANGE\ or\ NAME\fR] [\-\-get\-all\-exif]
.br
[\-\-get\-metadata\ \fIRANGE\ or\ NAME\fR] [\-\-get\-all\-metadata] [\-\-upload\-metadata\ \fIFILENAME\fR]
.br
[\-\-force\-overwrite]
Expand Down Expand Up @@ -399,6 +401,16 @@ Get audio data given in range\&.
Get all audio data from folder\&.
.RE
.PP
\fB\-\-get\-exif\fR \fIRANGE\fR
.RS 4
Get Exif given in range\&.
.RE
.PP
\fB\-\-get\-all\-exif\fR
.RS 4
Get all Exif from folder\&.
.RE
.PP
\fB\-\-upload\-metadata\fR \fIFILENAME\fR
.RS 4
Upload meta data for the specific file, taken from a file prefix with meta_ \&.
Expand Down Expand Up @@ -708,6 +720,11 @@ get\-raw \fIFILENAME\fR
Download the specified raw data to the current directory\&.
.RE
.PP
get\-exif \fIFILENAME\fR
.RS 4
Download the specified Exif data to the current directory\&.
.RE
.PP
show\-info \fIFILENAME\fR
.RS 4
Show information of the specified file\&.
Expand Down
13 changes: 13 additions & 0 deletions gphoto2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ typedef enum {
ARG_FOLDER,
ARG_FORCE_OVERWRITE,
ARG_GET_ALL_AUDIO_DATA,
ARG_GET_ALL_EXIF,
ARG_GET_ALL_FILES,
ARG_GET_ALL_METADATA,
ARG_GET_ALL_RAW_DATA,
Expand All @@ -1316,6 +1317,7 @@ typedef enum {
ARG_SET_CONFIG,
ARG_SET_CONFIG_INDEX,
ARG_SET_CONFIG_VALUE,
ARG_GET_EXIF,
ARG_GET_FILE,
ARG_GET_METADATA,
ARG_GET_RAW_DATA,
Expand Down Expand Up @@ -1636,6 +1638,9 @@ cb_arg_run (poptContext __unused__ ctx,
case ARG_GET_ALL_AUDIO_DATA:
params->p.r = for_each_file (&gp_params, save_all_audio_action);
break;
case ARG_GET_ALL_EXIF:
params->p.r = for_each_file (&gp_params, save_exif_action);
break;
case ARG_GET_ALL_FILES:
params->p.r = for_each_file (&gp_params, save_file_action);
break;
Expand All @@ -1656,6 +1661,10 @@ cb_arg_run (poptContext __unused__ ctx,
gp_params.multi_type = MULTI_DOWNLOAD;
params->p.r = get_file_common (arg, GP_FILE_TYPE_METADATA);
break;
case ARG_GET_EXIF:
gp_params.multi_type = MULTI_DOWNLOAD;
params->p.r = get_file_common (arg, GP_FILE_TYPE_EXIF);
break;
case ARG_GET_FILE:
gp_params.multi_type = MULTI_DOWNLOAD;
params->p.r = get_file_common (arg, GP_FILE_TYPE_NORMAL);
Expand Down Expand Up @@ -2125,6 +2134,10 @@ main (int argc, char **argv, char **envp)
{"get-all-audio-data", '\0', POPT_ARG_NONE, NULL,
ARG_GET_ALL_AUDIO_DATA,
N_("Get all audio data from folder"), NULL},
{"get-exif", '\0', POPT_ARG_STRING, NULL, ARG_GET_EXIF,
N_("Get files given in range"), N_("RANGE")},
{"get-all-exif", '\0', POPT_ARG_NONE, NULL, ARG_GET_ALL_EXIF,
N_("Get all files from folder"), NULL},
{"delete-file", 'd', POPT_ARG_STRING, NULL, ARG_DELETE_FILE,
N_("Delete files given in range"), N_("RANGE")},
{"delete-all-files", 'D', POPT_ARG_NONE, NULL,
Expand Down
12 changes: 12 additions & 0 deletions gphoto2/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static int shell_get (Camera *, const char *);
static int shell_put (Camera *, const char *);
static int shell_get_thumbnail (Camera *, const char *);
static int shell_get_raw (Camera *, const char *);
static int shell_get_exif (Camera *, const char *);
static int shell_del (Camera *, const char *);
static int shell_help (Camera *, const char *);
static int shell_ls (Camera *, const char *);
Expand Down Expand Up @@ -134,6 +135,8 @@ static const struct _ShellFunctionTable {
N_("[directory/]filename"), 1},
{"get-raw", shell_get_raw, N_("Download raw data"),
N_("[directory/]filename"), 1},
{"get-exif", shell_get_exif, N_("Download Exif data"),
N_("[directory/]filename"), 1},
{"show-info", shell_show_info, N_("Show image information, like width, height, and capture time"),
N_("[directory/]filename"), 1},
{"delete", shell_del, N_("Delete"), N_("[directory/]filename"), 1},
Expand Down Expand Up @@ -751,6 +754,15 @@ shell_get_raw (Camera __unused__ *camera, const char *arg)
return (GP_OK);
}

static int
shell_get_exif (Camera __unused__ *camera, const char *arg)
{
CHECK (shell_file_action (p->camera, p->context, p->folder, arg,
save_exif_action));

return (GP_OK);
}

static int
shell_del (Camera __unused__ *camera, const char *arg)
{
Expand Down

0 comments on commit 7635be2

Please sign in to comment.