Skip to content

Commit

Permalink
img2webp: add a warning for unused options
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jzern committed Dec 11, 2024
1 parent 1b4c967 commit e4f7a9f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/img2webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e4f7a9f

Please sign in to comment.