Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

Graphics File Formats FAQ (Part 4 of 4): Tips and Tricks of the Trade
Section - 4. What are the format identifiers of some popular file formats?

( Part1 - Part2 - Part3 - Part4 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Restaurant inspections ]


Top Document: Graphics File Formats FAQ (Part 4 of 4): Tips and Tricks of the Trade
Previous Document: 3. How can I identify the format of a graphics file?
Next Document: III. Kudos and Assertions
See reader questions & answers on this topic! - Help others by sharing your knowledge
Here are a few algorithms that you can use to determine the format of a
graphics file at run-time.


GIF: The first six bytes of a GIF file will be the byte pattern of 
     474946383761h ("GIF87a") or 474946383961h ("GIF89a").

JFIF: The first three bytes are ffd8ffh (i.e., an SOI marker followed
      by any marker). Do not check the fourth byte, as it will vary.

JPEG: The first three bytes are ffd8ffh (i.e., an SOI marker followed
      by any marker). Do not check the fourth byte, as it will vary.
      This works with most variants of "raw JPEG" as well.

PNG: The first eight bytes of all PNG files are 89504e470d0a1a0ah.

SPIFF: The first three bytes are ffd8ffh (i.e., an SOI marker followed
       by any marker). Do not check the fourth byte, as it will vary.

Sun: The first four bytes of a Sun Rasterfile are 59a66a95h. If you have
     accidentally read this identifier using the little-endian byte order
     this value will will be read as 956aa659h.

TGA: The last 18 bytes of a TGA Version 2 file is the string
     "TRUEVISION-XFILE.\0". If this string is not present, then the file
     is assumed to be a TGA Version 1 file.

TIFF: The first four bytes of a big-endian TIFF files are 4d4d002ah and
      49492a00h for little-endian TIFF files.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: Graphics File Formats FAQ (Part 4 of 4): Tips and Tricks of the Trade
Previous Document: 3. How can I identify the format of a graphics file?
Next Document: III. Kudos and Assertions

Part1 - Part2 - Part3 - Part4 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
jdm@ora.com (James D. Murray)





Last Update March 27 2014 @ 02:11 PM