Skip to content

WebP output with EXIF metadata is malformed #3140

@njdoyle

Description

@njdoyle

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am using the latest version of ImageMagick
  • I have searched open and closed issues to ensure it has not already been reported

Description

When using ImageMagick to convert an image with EXIF metadata to WebP, the EXIF data is not properly copied in to the WebP image.

Specifically, ImageMagick seems to be adding an extra "Exif" and two NULLs at the beginning of the EXIF data in the WebP EXIF chunk. By comparison, cwebp does not add this extra data. This extra data breaks proper parsing of this chunk.

I've attached a Zip with three files: an input JPEG with EXIF data input.jpg, an output WebP image made using ImageMagick output.magick.webp, and an output WebP image made using cwebp output.cwebp.webp.

WebPExif.zip

EXIF data always starts with MM or II.

The WebP EXIF metadata chunk is described here: https://developers.google.com/speed/webp/docs/riff_container#metadata

In output.cwebp.webp the EXIF chunk starts at 0x00003996 where you can see the well-formed EXIF chunk:

% hexdump -C output.cwebp.webp
...
00003990  bc ce 53 08 00 00 45 58  49 46 cc 08 00 00 4d 4d  |..S...EXIF....MM|
000039a0  00 2a 00 00 00 08 00 0b  01 0f 00 02 00 00 00 06  |.*..............|
...

In output.magick.webp the EXIF chunk starts at 0x00007A74 where you can see the malformed EXIF chunk:

% hexdump -C output.magick.webp
...
00007a70  4e ce 00 00 45 58 49 46  d2 08 00 00 45 78 69 66  |N...EXIF....Exif|
00007a80  00 00 4d 4d 00 2a 00 00  00 08 00 0b 01 0f 00 02  |..MM.*..........|
...

Steps to Reproduce

Assuming an input JPEG image with EXIF data, input.jpg.

Convert it to WebP using ImageMagick:

magick input.jpg output.magick.webp

Notice that output.magick.webp has incorrect EXIF data.

For comparison, convert the same input image to WebP using cwebp:

cwebp -metadata exif input.jpg -o output.cwebp.webp

Notice that output.magick.webp has correct EXIF data.

System Configuration

  • ImageMagick version: 7.0.10-58
  • Environment (Operating system, version and so on): Ubuntu 18.04 x86_64
  • Additional information:
% magick -version
Version: ImageMagick 7.0.10-58 Q16 x86_64 2021-01-16 https://imagemagick.org
Copyright: © 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI
Delegates (built-in): bzlib freetype heic jng jp2 jpeg lcms png tiff webp xml zlib
% magick -list configure

Path: [built-in]

Name                  Value
-------------------------------------------------------------------------------
DELEGATES             bzlib freetype heic jng jp2 jpeg lcms png tiff webp xml zlib
FEATURES              Cipher DPC HDRI
MAGICK_TEMPORARY_PATH /tmp
NAME                  ImageMagick
QuantumDepth          Q16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions