Issue 520 in webp: Custom meta information is lost when converting

83 views
Skip to first unread message

roman… via monorail

unread,
May 12, 2021, 12:15:32 AM5/12/21
to webp-d...@webmproject.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 520 by roman...@gmail.com: Custom meta information is lost when converting
https://bugs.chromium.org/p/webp/issues/detail?id=520

I am adding my own property for images uploaded to my server. The "my_custom_property" property contains json with settings for displaying watermarks.

Here is the complete information about the picture:

➜ identify -verbose 1.png
Image:
Filename: 1.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 1000x1000+0+0
Resolution: 118.11x118.11
Print size: 8.46668x8.46668
Units: PixelsPerCentimeter
Colorspace: sRGB
Type: TrueColor
Base type: Undefined
Endianness: Undefined
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Channel statistics:
Pixels: 1000000
Red:
min: 0 (0)
max: 255 (1)
mean: 228.191 (0.894868)
median: 255 (1)
standard deviation: 48.0874 (0.188578)
kurtosis: 9.16406
skewness: -3.05655
entropy: 0.708655
Green:
min: 0 (0)
max: 255 (1)
mean: 214.664 (0.841821)
median: 255 (1)
standard deviation: 57.5566 (0.225712)
kurtosis: 3.17187
skewness: -1.88935
entropy: 0.766894
Blue:
min: 0 (0)
max: 255 (1)
mean: 218.099 (0.855291)
median: 255 (1)
standard deviation: 58.1385 (0.227994)
kurtosis: 5.50993
skewness: -2.44278
entropy: 0.758478
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 220.318 (0.863993)
median: 255 (1)
standard deviation: 54.5941 (0.214095)
kurtosis: 5.44447
skewness: -2.40055
entropy: 0.744676
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1000x1000+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Profiles:
Profile-icc: 560 bytes
Properties:
date:create: 2021-05-12T03:45:33+00:00
date:modify: 2021-05-12T03:45:33+00:00
icc:copyright: Copyright 1999 Adobe Systems Incorporated
icc:description: Adobe RGB (1998)
my_custom_property: {"foo":"bar"}
png:bKGD: chunk was found (see Background color, above)
png:cHRM: chunk was found (see Chromaticity, above)
png:iCCP: chunk was found
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 2
png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 1000, 1000
png:pHYs: x_res=11811, y_res=11811, units=1
png:text: 6 tEXt/zTXt/iTXt chunks were found
png:text-encoded profiles: 1 were found
signature: 46de946cab144f67e7d304fc953783cd67bd190eadc7e5e9d573e9c68060c39c
Artifacts:
verbose: true
Tainted: False
Filesize: 1.3099MiB
Number pixels: 1000000
Pixels per second: 26.291MP
User time: 0.040u
Elapsed time: 0:01.038
Version: ImageMagick 7.0.11-7 Q16 x86_64 2021-04-12 https://imagemagick.org


I am doing a png to webp conversion:

➜ webp cwebp -metadata all -lossless 1.png -o 1.webp
Saving file '1.webp'
File: 1.png
Dimension: 1000 x 1000
Output: 1053234 bytes (8.43 bpp)
Lossless-ARGB compressed size: 1053234 bytes
* Header size: 7692 bytes, image data size: 1045516
* Lossless features used: PREDICTION CROSS-COLOR-TRANSFORM SUBTRACT-GREEN
* Precision Bits: histogram=5 transform=5 cache=10
Metadata:
* ICC profile: 560 bytes


Got the result:

➜ identify -verbose 1.webp
Image:
Filename: 1.webp
Format: WEBP (WebP Image Format)
Mime type: image/webp
Class: DirectClass
Geometry: 1000x1000+0+0
Units: Undefined
Colorspace: sRGB
Type: TrueColor
Base type: Undefined
Endianness: Undefined
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Channel statistics:
Pixels: 1000000
Red:
min: 0 (0)
max: 255 (1)
mean: 228.191 (0.894868)
median: 255 (1)
standard deviation: 48.0874 (0.188578)
kurtosis: 9.16406
skewness: -3.05655
entropy: 0.708655
Green:
min: 0 (0)
max: 255 (1)
mean: 214.664 (0.841821)
median: 255 (1)
standard deviation: 57.5566 (0.225712)
kurtosis: 3.17187
skewness: -1.88935
entropy: 0.766894
Blue:
min: 0 (0)
max: 255 (1)
mean: 218.099 (0.855291)
median: 255 (1)
standard deviation: 58.1385 (0.227994)
kurtosis: 5.50993
skewness: -2.44278
entropy: 0.758478
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 220.318 (0.863993)
median: 255 (1)
standard deviation: 54.5941 (0.214095)
kurtosis: 5.44447
skewness: -2.40055
entropy: 0.744676
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1000x1000+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Quality: 100
Orientation: Undefined
Properties:
date:create: 2021-05-12T03:50:21+00:00
date:modify: 2021-05-12T03:50:21+00:00
signature: 46de946cab144f67e7d304fc953783cd67bd190eadc7e5e9d573e9c68060c39c
Artifacts:
verbose: true
Tainted: False
Filesize: 1053820B
Number pixels: 1000000
Pixels per second: 24.4613MP
User time: 0.040u
Elapsed time: 0:01.040
Version: ImageMagick 7.0.11-7 Q16 x86_64 2021-04-12 https://imagemagick.org


looks like the "my_custom_property" property has been removed. exiftool doesn't find either

➜ exiftool --tagsFromFile 1.webp
ExifTool Version Number : 10.80
File Name : 1.webp
Directory : .
File Size : 1029 kB
File Modification Date/Time : 2021:05:12 11:02:10+07:00
File Access Date/Time : 2021:05:12 10:54:46+07:00
File Inode Change Date/Time : 2021:05:12 11:02:10+07:00
File Permissions : rw-rw-r--
File Type : WEBP
File Type Extension : webp
MIME Type : image/webp
Profile CMM Type : Adobe Systems Inc.
Profile Version : 2.1.0
Profile Class : Display Device Profile
Color Space Data : RGB
Profile Connection Space : XYZ
Profile Date Time : 1999:06:03 00:00:00
Profile File Signature : acsp
Primary Platform : Apple Computer Inc.
CMM Flags : Not Embedded, Independent
Device Manufacturer : none
Device Model :
Device Attributes : Reflective, Glossy, Positive, Color
Rendering Intent : Perceptual
Connection Space Illuminant : 0.9642 1 0.82491
Profile Creator : Adobe Systems Inc.
Profile ID : 0
Profile Copyright : Copyright 1999 Adobe Systems Incorporated
Profile Description : Adobe RGB (1998)
Media White Point : 0.95045 1 1.08905
Media Black Point : 0 0 0
Red Tone Reproduction Curve : (Binary data 14 bytes, use -b option to extract)
Green Tone Reproduction Curve : (Binary data 14 bytes, use -b option to extract)
Blue Tone Reproduction Curve : (Binary data 14 bytes, use -b option to extract)
Red Matrix Column : 0.60974 0.31111 0.01947
Green Matrix Column : 0.20528 0.62567 0.06087
Blue Matrix Column : 0.14919 0.06322 0.74457
Image Width : 1000
Image Height : 1000
Image Size : 1000x1000
Megapixels : 1.0


I am using this software:

➜ uname -a
Linux roman-pc 5.4.0-72-generic #80~18.04.1-Ubuntu SMP Mon Apr 12 23:26:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

➜ cwebp -version
1.2.0

➜ /sbin/ldconfig -p | grep libwebp
libwebpmux.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libwebpmux.so.3
libwebpdemux.so.2 (libc6,x86-64) => /usr/local/lib/libwebpdemux.so.2
libwebpdemux.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libwebpdemux.so.2
libwebpdemux.so (libc6,x86-64) => /usr/local/lib/libwebpdemux.so
libwebp.so.7 (libc6,x86-64) => /usr/local/lib/libwebp.so.7
libwebp.so.6 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libwebp.so.6
libwebp.so (libc6,x86-64) => /usr/local/lib/libwebp.so

➜ apt list --installed | grep webp
libwebp6/bionic,now 0.6.1-2 amd64 [installed]
libwebpdemux2/bionic,now 0.6.1-2 amd64 [installed]
libwebpmux3/bionic,now 0.6.1-2 amd64 [installed]
webp/bionic,now 0.6.1-2 amd64 [installed]


How to preserve "my_custom_property" when converting images to webp?

--
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

pasca… via monorail

unread,
May 12, 2021, 4:34:55 AM5/12/21
to webp-d...@webmproject.org

Comment #1 on issue 520 by pasca...@gmail.com: Custom meta information is lost when converting
https://bugs.chromium.org/p/webp/issues/detail?id=520#c1

Thanks for the detailed report!

Could you attach, if possible, the source image '1.png' containing the custom property?

roman… via monorail

unread,
May 12, 2021, 4:55:29 AM5/12/21
to webp-d...@webmproject.org

Comment #2 on issue 520 by roman...@gmail.com: Custom meta information is lost when converting
https://bugs.chromium.org/p/webp/issues/detail?id=520#c2

Yes, of course, here is the original image

Attachments:
1.png 1.3 MB

roman… via monorail

unread,
May 17, 2021, 10:28:16 PM5/17/21
to webp-d...@webmproject.org

Comment #3 on issue 520 by roman...@gmail.com: Custom meta information is lost when converting
https://bugs.chromium.org/p/webp/issues/detail?id=520#c3

Could you have any feedback on this issue? Will there be support for saving custom fields when converting?

jz… via monorail

unread,
May 17, 2021, 10:50:45 PM5/17/21
to webp-d...@webmproject.org
Updates:
Status: Accepted

Comment #4 on issue 520 by jz...@google.com: Custom meta information is lost when converting
https://bugs.chromium.org/p/webp/issues/detail?id=520#c4

The -all option is a bit of a misnomer in that it was meant to encompass the exif/icc/xmp options. At a minimum we should be able to add custom chunk additions via webpmux. I'm not sure if we'd be able to guarantee we'd be able to successfully extract all custom metadata from the types cwebp supports.

pasca… via monorail

unread,
May 18, 2021, 4:53:51 AM5/18/21
to webp-d...@webmproject.org

Comment #5 on issue 520 by pasca...@gmail.com: Custom meta information is lost when converting
https://bugs.chromium.org/p/webp/issues/detail?id=520#c5

Hi,

i had a quick look and the PNG parser is actually seeing these special metadata chunks (pngdec.c:165) but discards them as non EXIF/XMP.
The problem is that they are specific to PNG and not carried as regular EXIF/XMP data, which are the ones supported by libwebp.
As such, they are also lost if you convert e.g. to TIFF format (or JPG, even).

Have you considered incorporating your special property in a regular EXIF chunk?
Adding custom chunks to webp is likely to be a long process...

roman… via monorail

unread,
May 18, 2021, 5:54:52 AM5/18/21
to webp-d...@webmproject.org

Comment #6 on issue 520 by roman...@gmail.com: Custom meta information is lost when converting
https://bugs.chromium.org/p/webp/issues/detail?id=520#c6

Thank you for your responses!

I have reasons to stop using the EXIF ​​block normally, so I am using a custom field.

If it can really take a long time to add support for custom fields, I will try using standard EXIF, but I'm not sure if this option will be quick for me.

Can you give an approximate timeline for adding custom property support? Then I can choose which option will be faster.

jz… via monorail

unread,
May 18, 2021, 8:32:12 PM5/18/21
to webp-d...@webmproject.org

Comment #7 on issue 520 by jz...@google.com: Custom meta information is lost when converting
https://bugs.chromium.org/p/webp/issues/detail?id=520#c7

The container itself supports arbitrary chunks as it's derived from RIFF [1]. As a workaround for now you could append the chunk manually with its header and update the RIFF file size. That could be something that webpmux could do as well if support were added. The mux API already supports unknown chunks via WebPMuxSetChunk() [2].

[1] https://developers.google.com/speed/webp/docs/riff_container
[2] https://developers.google.com/speed/webp/docs/container-api#mux_api
Reply all
Reply to author
Forward
0 new messages