Project

General

Profile

The Metadata in WEBP files » History » Version 3

Robin Mills, 17 Aug 2016 15:51

1 1 Ben Touchette
h1. The Metadata in WEBP (.webp) files (Under construction)
2
3
Please note: Four bytes words in caps have special significance in this document, which are called Chunk headers, and appear exactly same in the original WebP file.
4
  
5
This page brief is about the WebP type image file container.
6
7
h2.  What is WebP?
8
9
Webp is a structured image container format (similar to the RIFF video format) issued from Google based on technology it acquired from ON2 Technologies.
10
11
h2. How it is structured?
12
13 2 Ben Touchette
Everything in WepB is structured in Chunk, sub-chunk hierarchy.  Every chunk contains ChunkID, ChunkSize, and ChunkData.  First four bytes of a WebP file type must be ASCII values corresponding to the letters *RIFF* followed at offset 8 (in bytes) by the ASCII values corresponding to the letters *WEBP*.  This is the ChunkId parent of every other sub-chunk.  Similar to the rules dominating RIFF structure which describe how a typical RIFF and WebP file are:
14 1 Ben Touchette
15
* Every chunk should have ChunkId(four bytes), ChunkSize(four bytes).  Do not include size of ChunkId and ChunkSize in ChunkSize.
16
* ChunkData having odd number of bytes should be padded with one more dummy byte, and ChunkSize is always even.
17
* ChunkData can be simple data like animation frames, or another Chunk having similar structure as parent Chunk.
18
* Every chunk will have data which has to be decoded according to either predefined schema or variable size metadata chunks.
19 3 Robin Mills
20
h2. Recovering the metadata in a WebP file
21
22
Exiv2 seamlessly parses and presents the metadata in a WebP file in the same way that it does for JPEG, TIFF, PNG and other formats.  For example: <pre>509 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -pa --grep Model/i test/data/exiv2-bug1199.webp 
23
Exif.Image.Model                             Ascii      12  NIKON D5300
24
510 rmills@rmillsmbp:~/gnu/exiv2/trunk $ </pre>Options are provide by the exiv2 to insert, modify and delete delete metadata.  Consult man (1) exiv2 for more information. 
25
26
h2. Examining the structure of a WebP file
27
28
Exiv2 supports the options -pS and -pR for WebP files.  The option -pS reports the structure of a file.  For example: <pre>507 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -pS test/data/exiv2-bug1199.webp 
29
STRUCTURE OF WEBP FILE: test/data/exiv2-bug1199.webp
30
 Chunk |   Length |   Offset | Payload
31
  RIFF |   187536 |        0 | WEBP
32
  VP8X |       10 |       12 | ,........
33
  ICCP |      560 |       30 | ...0ADBE....mntrRGB XYZ ........
34
  VP8  |   172008 |      598 | .G...*.. .>1..B.!..o.. ......]..
35
  EXIF |    12050 |   172614 | ../.Exif..II*..................
36
  XMP  |     2864 |   184672 | <?xpacket begin="..." id="W5M0Mp</pre>The options -pR recursively prints the structure of a file and descends into TIFF, ICC, IPTC, Exiv2 data structures.  For Example:<pre>
37
508 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -pR test/data/exiv2-bug1199.webp 
38
STRUCTURE OF WEBP FILE: test/data/exiv2-bug1199.webp
39
 Chunk |   Length |   Offset | Payload
40
  RIFF |   187536 |        0 | WEBP
41
  VP8X |       10 |       12 | ,........
42
  ICCP |      560 |       30 | ...0ADBE....mntrRGB XYZ ........
43
  VP8  |   172008 |      598 | .G...*.. .>1..B.!..o.. ......]..
44
  EXIF |    12050 |   172614 | ../.Exif..II*..................
45
  STRUCTURE OF TIFF FILE (??): MemIo
46
  END MemIo
47
  XMP  |     2864 |   184672 | <?xpacket begin="..." id="W5M0Mp
48
509 rmills@rmillsmbp:~/gnu/exiv2/trunk $ </pre>
49
50
h2. Metadata types in WebP
51
52
WebP files currently have chunkIDs defined for Exif, XMP, and ICC profile.  IPTC data structures are no normally found in WebP files.  However the exiv2 utility is equipped with conversion functions which convert XMP and EXIF metadata into equivalent IPTC Keys.  These can be reported.  For example: <pre>511 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -pi test/data/exiv2-bug1199.webp 
53
Iptc.Application2.ObjectName                 String     10  Stonehenge
54
Iptc.Envelope.CharacterSet                   String      3  G
55
Iptc.Application2.Byline                     String     11  Robin Mills
56
Iptc.Application2.BylineTitle                String     10  Stonehenge
57
Iptc.Application2.Caption                    String     12  Classic View
58
512 rmills@rmillsmbp:~/gnu/exiv2/trunk $ </pre>Please be aware that this is an artefact of the exiv2 application.  The IPTC metadata reported above is not stored in the file and therefore is probably not displayed by metadata applications which do not use libexiv2.  For example: Adobe Bridge has metadata inspectors which will not present those IPTC tags.