allow some more stdin/stout I/O

* allow reading from stdin for dwebp / vwebp
 * allow writing to stdout for gif2webp

by introducing a new function ExUtilReadFromStdin()

Example use: cat in.webp | dwebp -o - -- - > out.png

Note that the '-- -' option must appear *last*
(as per general fashion for '--' option parsing)

Change-Id: I8df0f3a246cc325925d6b6f668ba060f7dd81d68
This commit is contained in:
skal
2014-03-12 19:32:16 +01:00
parent 84ed4b3aa5
commit 2bcad89b4c
6 changed files with 71 additions and 11 deletions

View File

@ -501,7 +501,7 @@ int main(int argc, const char *argv[]) {
if (data == NULL) goto End; // Loop count sub-block missing.
if (data[0] != 3 && data[1] != 1) break; // wrong size/marker
anim.loop_count = data[2] | (data[3] << 8);
if (verbose) printf("Loop count: %d\n", anim.loop_count);
if (verbose) fprintf(stderr, "Loop count: %d\n", anim.loop_count);
} else { // An extension containing metadata.
// We only store the first encountered chunk of each type, and
// only if requested by the user.
@ -555,7 +555,8 @@ int main(int argc, const char *argv[]) {
// Add metadata chunk.
err = WebPMuxSetChunk(mux, fourccs[is_icc], &metadata, 1);
if (verbose) {
printf("%s size: %d\n", features[is_icc], (int)metadata.size);
fprintf(stderr, "%s size: %d\n",
features[is_icc], (int)metadata.size);
}
WebPDataClear(&metadata);
if (err != WEBP_MUX_OK) {
@ -621,11 +622,11 @@ int main(int argc, const char *argv[]) {
goto End;
}
if (!quiet) {
printf("Saved output file: %s\n", out_file);
fprintf(stderr, "Saved output file: %s\n", out_file);
}
} else {
if (!quiet) {
printf("Nothing written; use -o flag to save the result.\n");
fprintf(stderr, "Nothing written; use -o flag to save the result.\n");
}
}