add version getters for decoder and encoder

WebPGetDecoderVersion() and WebPGetEncoderVersion()
will not return 0.1.2 encoded as 0x000102

dwebp and cwebp also have a new "-version" flag

Change-Id: I4fb4b5a8fc4e53681a386ff4b74fffb639fa237a
This commit is contained in:
Pascal Massimino
2011-03-24 16:17:10 -07:00
parent be4867d2f8
commit 650ffa3bbb
8 changed files with 43 additions and 1 deletions

View File

@ -594,6 +594,7 @@ static void HelpLong() {
printf("\n");
printf(" -short ................. condense printed message\n");
printf(" -quiet ................. don't print anything.\n");
printf(" -version ............... print version number and exit.\n");
printf(" -v ..................... verbose, e.g. print encoding/decoding "
"times\n");
printf("\n");
@ -678,6 +679,11 @@ int main(int argc, const char *argv[]) {
crop_y = atoi(argv[++c]);
crop_w = atoi(argv[++c]);
crop_h = atoi(argv[++c]);
} else if (!strcmp(argv[c], "-version")) {
const int version = WebPGetEncoderVersion();
printf("%d.%d.%d\n",
(version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff);
return 0;
} else if (!strcmp(argv[c], "-quiet")) {
quiet = 1;
} else if (!strcmp(argv[c], "-preset") && c < argc - 1) {

View File

@ -205,12 +205,13 @@ typedef enum {
static void help(const char *s) {
printf("Usage: dwebp "
"[in_file] [-h] [-v] [-ppm] [-pgm] [-o out_file]\n\n"
"[in_file] [-h] [-v] [-ppm] [-pgm] [-version] [-o out_file]\n\n"
"Decodes the WebP image file to PNG format [Default]\n"
"Use following options to convert into alternate image formats:\n"
" -ppm: save the raw RGB samples as color PPM\n"
" -pgm: save the raw YUV samples as a grayscale PGM\n"
" file with IMC4 layout.\n"
" -version: print version number and exit.\n"
"Use -v for verbose (e.g. print encoding/decoding times)\n"
);
}
@ -232,6 +233,11 @@ int main(int argc, const char *argv[]) {
out_file = argv[++c];
} else if (!strcmp(argv[c], "-ppm")) {
format = PPM;
} else if (!strcmp(argv[c], "-version")) {
const int version = WebPGetDecoderVersion();
printf("%d.%d.%d\n",
(version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff);
return 0;
} else if (!strcmp(argv[c], "-pgm")) {
format = PGM;
} else if (!strcmp(argv[c], "-v")) {