From ab2d08a8425359c982599fb2730463669e61f55c Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 19 Nov 2020 19:15:57 -0800 Subject: [PATCH 1/2] [cd]webp: document lack of animated webp support Bug: webp:479 Change-Id: Iee2d7401400a5ff0a11682028194e561b365ab78 --- README | 5 ++++- examples/cwebp.c | 1 + examples/dwebp.c | 3 ++- man/cwebp.1 | 3 ++- man/dwebp.1 | 3 ++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README b/README index 0baba6ab..89be96f2 100644 --- a/README +++ b/README @@ -225,6 +225,7 @@ Usage: If input size (-s) for an image is not specified, it is assumed to be a PNG, JPEG, TIFF or WebP file. +Note: Animated PNG and WebP files are not supported. Options: -h / -help ............. short help @@ -344,7 +345,9 @@ The full list of options is available using -h: > dwebp -h Usage: dwebp in_file [options] [-o out_file] -Decodes the WebP image file to PNG format [Default] +Decodes the WebP image file to PNG format [Default]. +Note: Animated WebP files are not supported. + Use following options to convert into alternate image formats: -pam ......... save the raw RGBA samples as a color PAM -ppm ......... save the raw RGB samples as a color PPM diff --git a/examples/cwebp.c b/examples/cwebp.c index 68b960d2..927063a4 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -527,6 +527,7 @@ static void HelpLong(void) { printf(" cwebp [-preset <...>] [options] in_file [-o out_file]\n\n"); printf("If input size (-s) for an image is not specified, it is\n" "assumed to be a PNG, JPEG, TIFF or WebP file.\n"); + printf("Note: Animated PNG and WebP files are not supported.\n"); #ifdef HAVE_WINCODEC_H printf("Windows builds can take as input any of the files handled by WIC.\n"); #endif diff --git a/examples/dwebp.c b/examples/dwebp.c index cc75cb77..5cfb0fb1 100644 --- a/examples/dwebp.c +++ b/examples/dwebp.c @@ -76,7 +76,8 @@ static int SaveOutput(const WebPDecBuffer* const buffer, static void Help(void) { printf("Usage: dwebp in_file [options] [-o out_file]\n\n" - "Decodes the WebP image file to PNG format [Default]\n" + "Decodes the WebP image file to PNG format [Default].\n" + "Note: Animated WebP files are not supported.\n\n" "Use following options to convert into alternate image formats:\n" " -pam ......... save the raw RGBA samples as a color PAM\n" " -ppm ......... save the raw RGB samples as a color PPM\n" diff --git a/man/cwebp.1 b/man/cwebp.1 index 9bf3342d..89fc8ad3 100644 --- a/man/cwebp.1 +++ b/man/cwebp.1 @@ -1,5 +1,5 @@ .\" Hey, EMACS: -*- nroff -*- -.TH CWEBP 1 "January 11, 2019" +.TH CWEBP 1 "November 19, 2020" .SH NAME cwebp \- compress an image file to a WebP file .SH SYNOPSIS @@ -13,6 +13,7 @@ command. .PP \fBcwebp\fP compresses an image using the WebP format. Input format can be either PNG, JPEG, TIFF, WebP or raw Y'CbCr samples. +Note: Animated PNG and WebP files are not supported. .SH OPTIONS The basic options are: .TP diff --git a/man/dwebp.1 b/man/dwebp.1 index d4b60ed8..04168c4c 100644 --- a/man/dwebp.1 +++ b/man/dwebp.1 @@ -1,5 +1,5 @@ .\" Hey, EMACS: -*- nroff -*- -.TH DWEBP 1 "June 23, 2016" +.TH DWEBP 1 "November 19, 2020" .SH NAME dwebp \- decompress a WebP file to an image file .SH SYNOPSIS @@ -12,6 +12,7 @@ This manual page documents the command. .PP \fBdwebp\fP decompresses WebP files into PNG, PAM, PPM or PGM images. +Note: Animated WebP files are not supported. .SH OPTIONS The basic options are: .TP From 26faf7706bff08e5a47abdc85d3aa2bb2ec27c9d Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 19 Nov 2020 19:49:11 -0800 Subject: [PATCH 2/2] wicdec: fail with animated images this matches the behavior of other decoders (WebP) in imageio. Bug: webp:479 Change-Id: Ifcae0f38d7eebde31cd294070a6dd1f80cb30043 --- imageio/wicdec.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/imageio/wicdec.c b/imageio/wicdec.c index 249d1c21..a6694133 100644 --- a/imageio/wicdec.c +++ b/imageio/wicdec.c @@ -298,9 +298,15 @@ int ReadPictureWithWIC(const char* const filename, factory, stream, NULL, WICDecodeMetadataCacheOnDemand, &decoder)); IFS(IWICBitmapDecoder_GetFrameCount(decoder, &frame_count)); - if (SUCCEEDED(hr) && frame_count == 0) { - fprintf(stderr, "No frame found in input file.\n"); - hr = E_FAIL; + if (SUCCEEDED(hr)) { + if (frame_count == 0) { + fprintf(stderr, "No frame found in input file.\n"); + hr = E_FAIL; + } else if (frame_count > 1) { + // WIC will be tried before native WebP decoding so avoid duplicating the + // error message. + hr = E_FAIL; + } } IFS(IWICBitmapDecoder_GetFrame(decoder, 0, &frame)); IFS(IWICBitmapFrameDecode_GetPixelFormat(frame, &src_pixel_format));