file in abyss
フォーマット一覧へ戻る

Image

GIF Graphics Interchange Format

インデックスカラー画像と簡易アニメーションに使われる形式。GIF87a/GIF89aの2種のヘッダがあります。

Extensions .gif
MIME image/gif

マジックナンバー

ファイルを解析
オフセット 0 GIF87a header
47 49 46 38 37 61
GIF87a
オフセット 0 GIF89a header
47 49 46 38 39 61
GIF89a

構造

  1. Header
  2. Logical screen descriptor
  3. Global color table
  4. Image blocks
  5. Trailer

注意点

  • アニメーションGIFもGIF89aから始まることが多いです。

判定コード例

SIGNATURE = bytes.fromhex("474946383761")
OFFSET = 0

def is_gif(path: str) -> bool:
    with open(path, "rb") as f:
        f.seek(OFFSET)
        head = f.read(len(SIGNATURE))
    return head == SIGNATURE

実践的な使い方

ユースケース

Graphics Interchange Format は画像のプレビュー、サムネイル、メタデータ確認、アップロード検証などで広く使われます。解像度・アルファ・圧縮・ファイルサイズが実装の挙動に影響するため、複数のサイズでテストしてください。

よくある判定ミス

  • .gif という拡張子だけではファイルの中身を保証できません。アップロードや変換の処理では、拡張子・MIMEタイプ・先頭バイト・形式固有の構造チェックを組み合わせるべきです。
  • Graphics Interchange Format は 47 49 46 38 37 61 または 47 49 46 38 39 61 のようなシグネチャで始まりますが、関連するコンテナや破損ファイルでは追加の検証が必要になる場合があります。

セキュリティ上の注意

メディアファイルも、壊れたメタデータ・極端な寸法・長い再生時間・異常なチャンクでデコーダに負荷をかけることがあります。処理前にサイズ・寸法・長さを読み取ってください。

サンプルの活用

11 個のサンプルで、極小画像・高解像度画像・アルファチャンネル・圧縮しにくいアセットをテストできます。

サンプルファイル

11 / 11 files
Sample Traits Size Source / license / SHA-256
1x1 GIF preview

1x1 GIF

1x1 GIF is a Graphics Interchange Format sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.

1x1.gif
Type Sample
Small file
43 B
Generated CC0 1.0
SHA-256 b1442e85b03bdcaf66dc58c7abb98745dd2687d86350be9a298a1d9382ac849b
Download
Blue Sky GIF preview

Blue Sky GIF

Blue Sky GIF is a Graphics Interchange Format sample based on Wikimedia Commons, 96 x 72. It can be used to test downloads, parsers, previews, and file type detection.

01-blue-sky.gif
Resolution 96 x 72 7 Kpx
Preview
3.6 KB
SHA-256 4fe4554fb7eb8920681a37b43035b8cd6cdb94869ccbbca60d484b47e9371e1d
Download
Flower Garden GIF preview

Flower Garden GIF

Flower Garden GIF is a Graphics Interchange Format sample based on Wikimedia Commons, 160 x 90. It can be used to test downloads, parsers, previews, and file type detection.

02-flower-garden.gif
Resolution 160 x 90 14 Kpx
Preview
8.3 KB
SHA-256 eb1da0c8aec6b337ab6abc292a3cda4c8569a39d7e69bf57c16861e6f20315af
Download
Navy Blue Sky GIF preview

Navy Blue Sky GIF

Navy Blue Sky GIF is a Graphics Interchange Format sample based on Wikimedia Commons, 256 x 128. It can be used to test downloads, parsers, previews, and file type detection.

03-navy-blue-sky.gif
Resolution 256 x 128 33 Kpx
Preview
8.8 KB
SHA-256 dd308bc7618cc18f8e98e88125947ce91e33cd64ea848fd4aa576f3da7a3a1bd
Download
Nature of the Sky GIF preview

Nature of the Sky GIF

Nature of the Sky GIF is a Graphics Interchange Format sample based on Wikimedia Commons, 360 x 270. It can be used to test downloads, parsers, previews, and file type detection.

04-nature-sky.gif
Resolution 360 x 270 97 Kpx
Preview
17 KB
SHA-256 c6887346eeaf19a2072aa65bcb1b70ef5891913e4fc78e5be85e3e124803876b
Download
Sky Landscape GIF preview

Sky Landscape GIF

Sky Landscape GIF is a Graphics Interchange Format sample based on Wikimedia Commons, 512 x 384. It can be used to test downloads, parsers, previews, and file type detection.

05-sky-landscape.gif
Resolution 512 x 384 197 Kpx
Preview
48 KB
SHA-256 d4a52af9bb7c49d41ff42926b4708c698a9e03303d33df6a750787b2ebcab072
Download
Starry Sky GIF preview

Starry Sky GIF

Starry Sky GIF is a Graphics Interchange Format sample based on Wikimedia Commons, 720 x 480. It can be used to test downloads, parsers, previews, and file type detection.

06-starry-sky.gif
Resolution 720 x 480 346 Kpx
Preview
86 KB
SHA-256 dc373d7e797e546a709403ad8b648f630f1c2e78fb1dbc78247527789c6a0f99
Download
Blue Night Sky GIF preview

Blue Night Sky GIF

Blue Night Sky GIF is a Graphics Interchange Format sample based on Wikimedia Commons, 960 x 640. It can be used to test downloads, parsers, previews, and file type detection.

07-blue-night-sky.gif
Resolution 960 x 640 614 Kpx
Preview
277 KB
SHA-256 ad72a17789fbe7f26e9691fd6355e3672c4f7d2ba7d8dbd2d0a2942eb5d3fa7b
Download
Hibiscus Flower GIF preview

Hibiscus Flower GIF

Hibiscus Flower GIF is a Graphics Interchange Format sample based on Wikimedia Commons, 1280 x 2770. It can be used to test downloads, parsers, previews, and file type detection.

08-hibiscus-flower.gif
Resolution 1280 x 2770 3.5 MP
High resLarge file
1.34 MB
SHA-256 1284d2d2ae1365187adee386b5630766fb5452e2f61189342888b5adddf42065
Download
Arctic Sky GIF preview

Arctic Sky GIF

Arctic Sky GIF is a Graphics Interchange Format sample based on Wikimedia Commons, 1600 x 1062. It can be used to test downloads, parsers, previews, and file type detection.

09-arctic-sky.gif
Resolution 1600 x 1062 1.7 MP
Preview
625 KB
SHA-256 8c3e6a7a91f978f524a5b885c955ad22b912c71e62f7e6119a2b133c46499fd7
Download
NASA Blue Marble GIF preview

NASA Blue Marble GIF

NASA Blue Marble GIF is a Graphics Interchange Format sample based on NASA Image and Video Library, 640 x 640. It can be used to test downloads, parsers, previews, and file type detection.

nasa-blue-marble-2012-east.gif
Resolution 640 x 640 410 Kpx
Preview
112 KB
SHA-256 102a04cf58beec5478958cc4d88bf5b2ddd21d19aef22a2f3b67bb2e3f4f0760
Download

よくある質問

Graphics Interchange Format のマジックナンバー(ファイルシグネチャ)は?

Graphics Interchange Format ファイルはバイトシグネチャ 47 49 46 38 37 61 ("GIF87a") または 47 49 46 38 39 61 ("GIF89a") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。

Graphics Interchange Format のMIMEタイプは?

Graphics Interchange Format のMIMEタイプは image/gif です。

Graphics Interchange Format の拡張子は?

Graphics Interchange Format ファイルは .gif 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。

関連フォーマット