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

Image

PNG Portable Network Graphics

可逆圧縮のラスター画像形式。8バイトの固定シグネチャの直後にIHDRチャンクが続きます。

Extensions .png
MIME image/png

マジックナンバー

ファイルを解析
オフセット 0 PNGの固定8バイトシグネチャ
89 50 4E 47 0D 0A 1A 0A
.PNG....

構造

  1. Signature
  2. IHDR chunk
  3. Optional chunks
  4. IDAT chunk
  5. IEND chunk

注意点

  • APNGも同じPNGシグネチャから始まります。
  • 壊れたチャンクCRCでも先頭シグネチャだけは一致します。

判定コード例

SIGNATURE = bytes.fromhex("89504e470d0a1a0a")
OFFSET = 0

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

実践的な使い方

ユースケース

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

よくある判定ミス

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

セキュリティ上の注意

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

サンプルの活用

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

サンプルファイル

8 / 8 files
Sample Traits Size Source / license / SHA-256
Blue Sky PNG preview

Blue Sky PNG

Blue Sky PNG is a Portable Network Graphics sample based on Wikimedia Commons, 512 x 384. It can be used to test downloads, parsers, previews, and file type detection.

01-blue-sky.png
Resolution 512 x 384 197 Kpx
Preview
173 KB
SHA-256 8c4e8b9755c9a7a830220dbc1976923c1b25433377773567ed456ce64b6f5890
Download
Flower Garden PNG preview

Flower Garden PNG

Flower Garden PNG is a Portable Network Graphics sample based on Wikimedia Commons, 640 x 360. It can be used to test downloads, parsers, previews, and file type detection.

02-flower-garden.png
Resolution 640 x 360 230 Kpx
Preview
361 KB
SHA-256 936f1936e08d92332d322d1375d8bdce7acdbeb110659d7e56f0ba10eb9fe5c7
Download
Navy Blue Sky PNG preview

Navy Blue Sky PNG

Navy Blue Sky PNG is a Portable Network Graphics sample based on Wikimedia Commons, 768 x 383. It can be used to test downloads, parsers, previews, and file type detection.

03-navy-blue-sky.png
Resolution 768 x 383 294 Kpx
Preview
380 KB
SHA-256 0135de555c0d98a165ea21adddbe53f41477c1e2009162dca0b80ce3891de225
Download
Nature Sky PNG preview

Nature Sky PNG

Nature Sky PNG is a Portable Network Graphics sample based on Wikimedia Commons, 720 x 540. It can be used to test downloads, parsers, previews, and file type detection.

04-nature-sky.png
Resolution 720 x 540 389 Kpx
Preview
207 KB
SHA-256 7b34840dee4f5fecbea7aec51c9113ef7fcf4b08c38e21f3a9604d1b89f59513
Download
Sky Landscape PNG preview

Sky Landscape PNG

Sky Landscape PNG is a Portable Network Graphics sample based on Wikimedia Commons, 768 x 576. It can be used to test downloads, parsers, previews, and file type detection.

05-sky-landscape.png
Resolution 768 x 576 442 Kpx
Preview
486 KB
SHA-256 55ef3c8803651b27f7cef6214dba60c1ca73ffe427c529acba4bd642d853a8ea
Download
Blue Night Sky PNG preview

Blue Night Sky PNG

Blue Night Sky PNG is a Portable Network Graphics 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.png
Resolution 960 x 640 614 Kpx
PreviewLarge file
1.12 MB
SHA-256 e926f8cd9f981d98f256acaf82e2266733e7d8d1507861904b53ebf5508925d3
Download
NASA Earth 2048x2048 PNG preview

NASA Earth 2048x2048 PNG

NASA Earth 2048x2048 PNG is a Portable Network Graphics sample based on Wikimedia Commons, 2048 x 2048. It can be used to test downloads, parsers, previews, and file type detection.

nasa-earth-2022.png
Resolution 2048 x 2048 4.2 MP
High resLarge file
3.15 MB
SHA-256 f2bf466a5173fec5b3e0492312138c026d83dcd1c5980c45383d6684d07aad0a
Download
NASA Blue Marble PNG preview

NASA Blue Marble PNG

NASA Blue Marble PNG is a Portable Network Graphics 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.png
Resolution 640 x 640 410 Kpx
Preview
459 KB
SHA-256 245e1a4eecaf262b7bbab32320b42e80b378ecf89f1642f6b36df4c77f543056
Download

よくある質問

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

Portable Network Graphics ファイルはバイトシグネチャ 89 50 4E 47 0D 0A 1A 0A (".PNG....") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。

Portable Network Graphics のMIMEタイプは?

Portable Network Graphics のMIMEタイプは image/png です。

Portable Network Graphics の拡張子は?

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

関連フォーマット