Issue 562 in webp: Blackberry photo in jpeg with embedded TIFF image fails to convert to webp

44 views
Skip to first unread message

brian… via monorail

unread,
Mar 18, 2022, 1:18:01 AMMar 18
to webp-d...@webmproject.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 562 by brian...@gmail.com: Blackberry photo in jpeg with embedded TIFF image fails to convert to webp
https://bugs.chromium.org/p/webp/issues/detail?id=562

What steps will reproduce the problem?

$ cwebp -preset photo Sample.jpg -o Sample.webp

What is the expected output?

Saving file 'Sample.webp'
...

What do you see instead?

libjpeg error: Input file read error
Error! Could not process file Sample.jpg
Error! Cannot read input picture file 'Sample.jpg'

What version of the product are you using?

$ cygcheck -c `apt-cyg l webp | cut -d' ' -f1`
Cygwin Package Information
Package Version Status
libwebp 1.2.2-1 OK
libwebp-devel 1.2.2-1 OK
libwebp7 1.2.2-1 OK
libwebpdecoder3 1.2.2-1 OK
libwebpdemux2 1.2.2-1 OK
libwebpmux3 1.2.2-1 OK

On what operating system?

$ uname -srvmo
CYGWIN_NT-10.0 3.3.4(0.341/5/3) 2022-01-31 19:35 x86_64 Cygwin
$ win-ver
Windows 10 Home Client Core Multiprocessor Free 6.3 21H2 2009 vb_release 10 0 19044 1586

Please provide any additional information below.

Input jpeg is embedded TIFF image from Blackberry:

$ file Sample.jpg
Sample.jpg: JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=10, manufacturer=Research In Motion, model=BlackBerry 9790, orientation=upper-left, xresolution=170, yresolution=178, resolutionunit=2, software=Rim Exif Version1.00a, datetime=2012:07:24 18:59:04], baseline, precision 8, 2592x1944, components 3

Attachments:
Sample.jpg 858 KB

--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

brian… via monorail

unread,
Mar 18, 2022, 1:40:27 AMMar 18
to webp-d...@webmproject.org

Comment #1 on issue 562 by brian...@gmail.com: Blackberry photo in jpeg with embedded TIFF image fails to convert to webp
https://bugs.chromium.org/p/webp/issues/detail?id=562#c1

Image converts okay with Irfan View with no warnings and Image Magick gives warning but output appears identical:

$ magick Sample.jpg SampleJ.webp
magick: Premature end of JPEG file `Sample.jpg' @ warning/jpeg.c/JPEGWarningHandler/397.
magick: Corrupt JPEG data: premature end of data segment `Sample.jpg' @ warning/jpeg.c/JPEGWarningHandler/397.
$ ls -glo Sample.jpg SampleJ.webp
-rw-r--r-- 1 879321 Mar 17 22:29 Sample.jpg
-rw-r--r-- 1 583584 Mar 17 23:33 SampleJ.webp
$ file Sample.jpg SampleJ.webp

Sample.jpg: JPEG image data, Exif standard: [TIFF image data, little-endian, direntries=10, manufacturer=Research In Motion, model=BlackBerry 9790, orientation=upper-left, xresolution=170, yresolution=178, resolutionunit=2, software=Rim Exif Version1.00a, datetime=2012:07:24 18:59:04], baseline, precision 8, 2592x1944, components 3
SampleJ.webp: RIFF (little-endian) data, Web/P image

jz… via monorail

unread,
Mar 19, 2022, 12:02:24 AMMar 19
to webp-d...@webmproject.org

Comment #2 on issue 562 by jz...@google.com: Blackberry photo in jpeg with embedded TIFF image fails to convert to webp
https://bugs.chromium.org/p/webp/issues/detail?id=562#c2

This is a similar issue to https://crbug.com/webp/528. We rely on libjpeg to process the file and it's returning an error (from cwebp: libjpeg error: Input file read error, djpeg: Premature end of JPEG file).

brian… via monorail

unread,
Mar 23, 2022, 5:15:58 PMMar 23
to webp-d...@webmproject.org

Comment #3 on issue 562 by brian...@gmail.com: Blackberry photo in jpeg with embedded TIFF image fails to convert to webp
https://bugs.chromium.org/p/webp/issues/detail?id=562#c3

Image Magick and Irfan View both produce webp which display normally.

Brian Inglis

unread,
Apr 5, 2022, 10:14:37 PMApr 5
to WebP Discussion, brian… via monorail, no_r...@monorail-prod.appspotmail.com
Raised an upstream libjpeg-turbo issue and as it is documented that these embedded sections are not officially supported by original libjpeg, suggest that as in their and other JPEG utilities, browsers, Image Magick, Irfan View, etc. your library should report Premature End of JPEG as a warning, but your utilities could see if there is adequate metadata and data content available to generate an image, use it and save it. 
Or you should document that your library and utilities may fail to handle some JPEGs that cause the JPEG libraries to report errors, and that no recovery will be attampted, so other JPEG copy or conversion utilties may be used to generate well formed JPEGs, that your library and utilities can handle e.g. `jpegtran -copy all`. 

jz… via monorail

unread,
Apr 7, 2022, 7:41:19 PMApr 7
to webp-d...@webmproject.org

Comment #4 on issue 562 by jz...@google.com: Blackberry photo in jpeg with embedded TIFF image fails to convert to webp
https://bugs.chromium.org/p/webp/issues/detail?id=562#c4

From the reply on the mailing list:


> On Tue, Apr 5, 2022 at 7:14 PM Brian Inglis <brian.w...@gmail.com> wrote:
>
> Raised an upstream libjpeg-turbo issue

> documented that these embedded sections are not officially supported by
> original libjpeg, suggest that as in their and other JPEG utilities,
> browsers, Image Magick, Irfan View, etc. your library should report Premature
> End of JPEG as a warning, but your utilities could see if there is adequate
> metadata and data content available to generate an image, use it and save it.
>

We could output a potentially truncated image, but as dcommander points out [1], ignoring errors is not the safest practice when processing untrusted data.


> Or you should document that your library and utilities may fail to handle
> some JPEGs that cause the JPEG libraries to report errors, and that no
> recovery will be attampted, so other JPEG copy or conversion utilties may be
> used to generate well formed JPEGs, that your library and utilities can
> handle e.g. `jpegtran -copy all`.

We might be able to make this suggestion from cwebp when we encounter JERR_INPUT_EOF.

[1] https://github.com/libjpeg-turbo/libjpeg-turbo/issues/591#issuecomment-1089361911
Reply all
Reply to author
Forward
0 new messages