Viewing a WEBPVP8 image in a RIFF file

After downloading an image file from Google Drive to a MacBook Pro laptop running OS X 10.10.5, I found when I tried to open the file in the Preview application on the Mac, I couldn't open it with that application. I then right-clicked on the file in the Finder and chose "open with" then "other" and then tried the Photos application, but it couldn't open the file either. So I used the file utility, which can determine the format type for files based on a magic number contained within a file.
$ file Map
Map: RIFF (little-endian) data

The file program indicated that the file I downloaded, which was a campus map, was in the Resource Interchange File Format (RIFF), a file container format that was introduced by Microsoft and IBM in 1991; it was the default format for Microsoft Windows 3.1 multimedia files. The format is based on the Interchange File Format (IFF) introduced by Electronic Arts for the Commodore Amiga Amiga in 1985. However, whereas multi-byte integers are stored in big-endian format, which is a format native to the 68k processor series used in Amiga and Apple Macintosh computers, RIFF files use the little-endian format, which is why the file utility reports "RIFF (little-endian) data".

How does the file utility recognize it as a RIFF file? When the file program examines the first 4 bytes of the file, it sees the hexadecimal values 46 46 49 52, which identifies the file as a RIFF file - see The Dr. Agon WAV File Format Page for a full discussion of the format.

I can see that by using the od command.

$ od -t x -N 4 Map
0000000          46464952                                                
0000004
$

The -t x option instructs the od utility to display its output in hexadecimal and the -N 4 option tells it to display only the first 4 bytes of the file. Note: if you choose to display the data as hexadecimal shorts, instead, you will see the first 4 bytes listed as 49 52 46 46, but if you choose to display as hexadecimal ints, as above, you will see them displayed as 46464952.

     -H, -X      Output hexadecimal ints.  Equivalent to -t x4.

     -h, -x      Output hexadecimal shorts.  Equivalent to -t x2.

I.e.:

$ od -H -N 4 Map
0000000          46464952                                                
0000004
GSSLA15122293:convert-riff jmcamer1$ od -h -N 4 Map
0000000      4952    4646                                                
0000004

Since the RIFF file format is a container file format, I looked at the first 16 bytes to determine the type of image stored in the file. I used the -t a and -t c options for displaying the data this time to see the ASCII representation of the data in the file this time.

     -t type     Specify the output format.  type is a string containing one
                 or more of the following kinds of type specifiers:

                 a       Named characters (ASCII).  Control characters are
                         displayed using the following names:

                         000 NUL 001 SOH 002 STX 003 ETX 004 EOT 005 ENQ
                         006 ACK 007 BEL 008 BS  009 HT  00a NL  00b VT
                         00c FF  00d CR  00e SO  00f SI  010 DLE 011 DC1
                         012 DC2 013 DC3 014 DC4 015 NAK 016 SYN 017 ETB
                         018 CAN 019 EM  01a SUB 01b ESC 01c FS  01d GS
                         01e RS  01f US  020 SP  0ff DEL

                 c       Characters in the default character set.  Non-print-
                         ing characters are represented as 3-digit octal char-
                         acter codes, except the following characters, which
                         are represented as C escapes:

                         NUL              \0
                         alert            \a
                         backspace        \b
                         newline          \n
                         carriage-return  \r
                         tab              \t
                         vertical tab     \v

                         Multi-byte characters are displayed in the area cor-
                         responding to the first byte of the character. The
                         remaining bytes are shown as `**'.

That showed me that the file was a RIFF file with an image within it of WEBPVP8, which is a format used by Google.

$ od -t c -N 16 Map
0000000    R   I   F   F 320   p 002  \0   W   E   B   P   V   P   8    
0000020
GSSLA15122293:convert-riff jmcamer1$ od -t a -N 16 Map
0000000    R   I   F   F   ?   p stx nul   W   E   B   P   V   P   8  sp
0000020

Note the "R" in "RIFF" is represented by the hexadecimal value 52 in the ASCII encoding standard wile "I" is represented by hex 49 and "F" by 46.

I was able to view the file by opening it in the Google Chrome browser on the system by clicking on File from its menu bar, selecting Open File and then selecting the Map file.

References:

  1. The Dr. Agon WAV File Format Page
    Last Modified: November 27, 2010
    Get Tech'Ed
    Technical Education Home Page

 

TechRabbit ad 300x250 newegg.com

Justdeals Daily Electronics Deals1x1 px