From e4f7a9f0c7c9fbfae1568bc7fa5c94b989b50872 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 10 Dec 2024 17:29:59 -0800 Subject: [PATCH] img2webp: add a warning for unused options This may help prevent confusion when placing frame options after the target frame. Note for compatibility this isn't fatal, but the behavior may change in the future. Bug: webp:381372617 Change-Id: I9f3b51e60ff650ccc6fd29b8f5f607c3771a8a55 --- examples/img2webp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/img2webp.c b/examples/img2webp.c index 9cfccb43..97d2669e 100644 --- a/examples/img2webp.c +++ b/examples/img2webp.c @@ -151,6 +151,7 @@ int main(int argc, const char* argv[]) { WebPData webp_data; int c; int have_input = 0; + int last_input_index = 0; CommandLineArguments cmd_args; int ok; @@ -279,6 +280,7 @@ int main(int argc, const char* argv[]) { // read next input image pic.use_argb = 1; ok = ReadImage((const char*)GET_WARGV_SHIFTED(argv, c), &pic); + last_input_index = c; if (!ok) goto End; if (enc == NULL) { @@ -317,6 +319,13 @@ int main(int argc, const char* argv[]) { ++pic_num; } + for (c = last_input_index + 1; c < argc; ++c) { + if (argv[c] != NULL) { + fprintf(stderr, "Warning: unused option [%s]!" + " Frame options go before the input frame.\n", argv[c]); + } + } + // add a last fake frame to signal the last duration ok = ok && WebPAnimEncoderAdd(enc, NULL, timestamp_ms, NULL); ok = ok && WebPAnimEncoderAssemble(enc, &webp_data);