From 723847d5d71d891d8830a3171bc6eb68967bd683 Mon Sep 17 00:00:00 2001 From: James Zern Date: Sun, 17 Mar 2013 18:08:01 -0700 Subject: [PATCH] gif2webp: only write error messages to stderr also output something if -o is not given, but the process succeeded Change-Id: I466c377f0cbf8c9f45bb1839191b04dada9c5f0f --- examples/gif2webp.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/gif2webp.c b/examples/gif2webp.c index 5f4d275c..53694417 100644 --- a/examples/gif2webp.c +++ b/examples/gif2webp.c @@ -343,11 +343,11 @@ int main(int argc, const char *argv[]) { goto End; } if (verbose) { - fprintf(stderr, "Added frame %dx%d (offset:%d,%d duration:%d) ", - view.width, view.height, frame.x_offset, frame.y_offset, - frame.duration); - fprintf(stderr, "dispose:%d transparent index:%d\n", - frame.dispose_method, transparent_index); + printf("Added frame %dx%d (offset:%d,%d duration:%d) ", + view.width, view.height, frame.x_offset, frame.y_offset, + frame.duration); + printf("dispose:%d transparent index:%d\n", + frame.dispose_method, transparent_index); } WebPDataClear(&frame.bitstream); break; @@ -392,7 +392,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) fprintf(stderr, "Loop count: %d\n", anim.loop_count); + if (verbose) printf("Loop count: %d\n", anim.loop_count); } else if (!memcmp(data + 1, "XMP dataXMP", 11)) { // Read XMP metadata. WebPData xmp; @@ -401,7 +401,7 @@ int main(int argc, const char *argv[]) { xmp.bytes = (uint8_t*)data; xmp.size = data[0] + 1; WebPMuxSetChunk(mux, "XMP ", &xmp, 1); - if (verbose) fprintf(stderr, "XMP size: %zu\n", xmp.size); + if (verbose) printf("XMP size: %zu\n", xmp.size); } else if (!memcmp(data + 1, "ICCRGBG1012", 11)) { // Read ICC profile. WebPData icc; @@ -410,7 +410,7 @@ int main(int argc, const char *argv[]) { icc.bytes = (uint8_t*)data; icc.size = data[0] + 1; WebPMuxSetChunk(mux, "ICCP", &icc, 1); - if (verbose) fprintf(stderr, "ICC size: %zu\n", icc.size); + if (verbose) printf("ICC size: %zu\n", icc.size); } break; } @@ -454,7 +454,13 @@ int main(int argc, const char *argv[]) { fprintf(stderr, "Error writing output file: %s\n", out_file); goto End; } - if (!quiet) fprintf(stderr, "Saved output file: %s\n", out_file); + if (!quiet) { + printf("Saved output file: %s\n", out_file); + } + } else { + if (!quiet) { + printf("Nothing written; use -o flag to save the result.\n"); + } } // All OK.