add -version option to anim_dump,anim_diff and img2webp
This is to harmonize the -h/-version options on all our examples.
+ added GetAnimatedImageVersions() method to anim_util.*
Change-Id: I2304a1c29e310682e97f236d3867274a192a7a09
diff --git a/README b/README
index 5ddbfc9..a76b378 100644
--- a/README
+++ b/README
@@ -458,6 +458,7 @@
-mixed ............... use mixed lossy/lossless automatic mode
-v ................... verbose mode
-h ................... this help
+ -version ............. print version number and exit
Per-frame options (only used for subsequent images input):
-d <int> ............. frame duration in ms (default: 100)
@@ -527,6 +528,8 @@
-max_diff <int> ..... maximum allowed difference per channel
between corresponding pixels in subsequent
frames
+ -h .................. this help
+ -version ............ print version number and exit
Building:
---------
diff --git a/examples/anim_diff.c b/examples/anim_diff.c
index 7ac5689..e74a915 100644
--- a/examples/anim_diff.c
+++ b/examples/anim_diff.c
@@ -190,6 +190,8 @@
printf(" -max_diff <int> ..... maximum allowed difference per channel\n"
" between corresponding pixels in subsequent\n"
" frames\n");
+ printf(" -h .................. this help\n");
+ printf(" -version ............ print version number and exit\n");
}
int main(int argc, const char* argv[]) {
@@ -205,11 +207,6 @@
const char* files[2] = { NULL, NULL };
AnimatedImage images[2];
- if (argc < 3) {
- Help();
- return -1;
- }
-
for (c = 1; c < argc; ++c) {
int parse_error = 0;
if (!strcmp(argv[c], "-dump_frames")) {
@@ -247,6 +244,18 @@
} else {
parse_error = 1;
}
+ } else if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) {
+ Help();
+ return 0;
+ } else if (!strcmp(argv[c], "-version")) {
+ int dec_version, demux_version;
+ GetAnimatedImageVersions(&dec_version, &demux_version);
+ printf("WebP Decoder version: %d.%d.%d\nWebP Demux version: %d.%d.%d\n",
+ (dec_version >> 16) & 0xff, (dec_version >> 8) & 0xff,
+ (dec_version >> 0) & 0xff,
+ (demux_version >> 16) & 0xff, (demux_version >> 8) & 0xff,
+ (demux_version >> 0) & 0xff);
+ return 0;
} else {
if (!got_input1) {
files[0] = argv[c];
@@ -263,6 +272,12 @@
return -1;
}
}
+ if (argc < 3) {
+ Help();
+ return -1;
+ }
+
+
if (!got_input2) {
Help();
return -1;
diff --git a/examples/anim_dump.c b/examples/anim_dump.c
index b955b54..7b96cfe 100644
--- a/examples/anim_dump.c
+++ b/examples/anim_dump.c
@@ -30,6 +30,8 @@
"(default: 'dump_')\n");
printf(" -tiff ............... save frames as TIFF\n");
printf(" -pam ................ save frames as PAM\n");
+ printf(" -h .................. this help\n");
+ printf(" -version ............ print version number and exit\n");
}
int main(int argc, const char* argv[]) {
@@ -66,6 +68,18 @@
} else if (!strcmp(argv[c], "-pam")) {
format = PAM;
suffix = "pam";
+ } else if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) {
+ Help();
+ return 0;
+ } else if (!strcmp(argv[c], "-version")) {
+ int dec_version, demux_version;
+ GetAnimatedImageVersions(&dec_version, &demux_version);
+ printf("WebP Decoder version: %d.%d.%d\nWebP Demux version: %d.%d.%d\n",
+ (dec_version >> 16) & 0xff, (dec_version >> 8) & 0xff,
+ (dec_version >> 0) & 0xff,
+ (demux_version >> 16) & 0xff, (demux_version >> 8) & 0xff,
+ (demux_version >> 0) & 0xff);
+ return 0;
} else {
uint32_t i;
AnimatedImage image;
diff --git a/examples/anim_util.c b/examples/anim_util.c
index 800ea76..c7a05c7 100644
--- a/examples/anim_util.c
+++ b/examples/anim_util.c
@@ -786,3 +786,9 @@
*psnr = 4.3429448 * log(255. * 255. / sse);
}
}
+
+void GetAnimatedImageVersions(int* const decoder_version,
+ int* const demux_version) {
+ *decoder_version = WebPGetDecoderVersion();
+ *demux_version = WebPGetDemuxVersion();
+}
diff --git a/examples/anim_util.h b/examples/anim_util.h
index dbc9792..8063121 100644
--- a/examples/anim_util.h
+++ b/examples/anim_util.h
@@ -56,6 +56,10 @@
uint32_t width, uint32_t height, int premultiply,
int* const max_diff, double* const psnr);
+// Return library versions used by anim_util.
+void GetAnimatedImageVersions(int* const decoder_version,
+ int* const demux_version);
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/examples/img2webp.c b/examples/img2webp.c
index 052aa87..2f750c5 100644
--- a/examples/img2webp.c
+++ b/examples/img2webp.c
@@ -48,6 +48,7 @@
printf(" -mixed ............... use mixed lossy/lossless automatic mode\n");
printf(" -v ................... verbose mode\n");
printf(" -h ................... this help\n");
+ printf(" -version ............. print version number and exit\n");
printf("\n");
printf("Per-frame options (only used for subsequent images input):\n");
@@ -177,6 +178,14 @@
} else if (!strcmp(argv[c], "-h") || !strcmp(argv[c], "-help")) {
Help();
goto End;
+ } else if (!strcmp(argv[c], "-version")) {
+ const int enc_version = WebPGetEncoderVersion();
+ const int mux_version = WebPGetMuxVersion();
+ printf("WebP Encoder version: %d.%d.%d\nWebP Mux version: %d.%d.%d\n",
+ (enc_version >> 16) & 0xff, (enc_version >> 8) & 0xff,
+ enc_version & 0xff, (mux_version >> 16) & 0xff,
+ (mux_version >> 8) & 0xff, mux_version & 0xff);
+ goto End;
} else {
continue;
}
diff --git a/man/img2webp.1 b/man/img2webp.1
index 910c794..da1d91d 100644
--- a/man/img2webp.1
+++ b/man/img2webp.1
@@ -1,5 +1,5 @@
.\" Hey, EMACS: -*- nroff -*-
-.TH IMG2WEBP 1 "February 7, 2018"
+.TH IMG2WEBP 1 "April 3, 2018"
.SH NAME
img2webp \- create animated WebP file from a sequence of input images.
.SH SYNOPSIS
@@ -53,6 +53,9 @@
.TP
.B \-h, \-help
A short usage summary.
+.TP
+.B \-version
+Print the version numbers of the relevant libraries used.
.SH PER-FRAME OPTIONS
The per-frame options are applied for the images following as arguments in the