Free webp to jpg
PBM

Portable Bitmap

image/x-portable-bitmap Released 1988 · by Jef Poskanzer (Netpbm Project)

The image/x-portable-bitmap MIME type represents the Portable Bitmap (PBM) format, the simplest member of the Netpbm family of image formats. Created in the 1980s by Jef Poskanzer, PBM is designed strictly to store 1-bit monochrome (black and white) images without any compression. It supports two distinct encodings: a human-readable ASCII plaintext version (designated by the 'P1' magic number) where pixels are represented by '0' and '1' characters, and a raw binary version ('P4') that packs eight pixels into a single byte. Because of its extreme simplicity, it is widely used as an intermediary format in Unix-based image processing pipelines and optical character recognition (OCR) workflows.

Raster Graphics Production Ready

Technical Specifications

MIME Type
image/x-portable-bitmap
Extensions
.pbm
Container
Netpbm
Compression
Uncompressed
Algorithms
None
Color Depth
1-bit (Monochrome)
Metadata
None
Capabilities
Transparency
Animation
Progressive Loading
Alpha Channel
HDR Support
Official Specification
Aliases: image/pbm

Magic Bytes & HTTP Headers

File Signature (Magic Bytes)
50 31 (ASCII) or 50 34 (Binary)
ASCII: P1 or P4
HTTP Headers
Content-Type: image/x-portable-bitmap
HTML Accept Attribute
accept="image/x-portable-bitmap, .pbm"

Browser Support Matrix

Browser Status Min Version
Chrome Chrome
Not Supported
Firefox Firefox
Not Supported
Safari Safari
Not Supported
Edge Edge
Not Supported
Internet Explorer Internet Explorer
Not Supported Legacy

Advantages & Limitations

Advantages
  • Absolute structural simplicity allows parsers to be written from scratch with just a few lines of code
  • ASCII encoding allows manual editing and debugging directly within a standard text editor
  • Serves as a flawless, lossless intermediary for 1-bit raster data like scanned documents or barcodes
Limitations
  • Strictly limited to 1-bit monochrome images; cannot natively display shades of gray or color
  • Lack of compression results in extremely large file sizes, particularly when using the ASCII 'P1' encoding
  • No support for alpha transparency or modern metadata standards like EXIF

Developer Code Snippets

import magic
# Libmagic natively detects PBM files
print(magic.from_file('scanned_doc.pbm', mime=True)) # Outputs 'image/x-portable-bitmap'
const fs = require('fs');
// Manually checking the PBM magic bytes (P1 or P4)
const buffer = Buffer.alloc(2);
const fd = fs.openSync('scanned_doc.pbm', 'r');
fs.readSync(fd, buffer, 0, 2, 0);
fs.closeSync(fd);
const isPBM = buffer[0] === 0x50 && (buffer[1] === 0x31 || buffer[1] === 0x34);
console.log('Is Portable Bitmap (PBM):', isPBM);
import (
    "bytes"
    "net/http"
)
// Native Go HTTP detection does not recognize PBM natively.
// Check directly for the P1 or P4 signatures:
// isPBM := len(buf) >= 2 && buf[0] == 'P' && (buf[1] == '1' || buf[1] == '4')
$mime = mime_content_type('scanned_doc.pbm');
echo $mime; // Standard PHP setups typically return 'image/x-portable-bitmap'

File Detection Steps

How to programmatically detect a image/x-portable-bitmap file by reading its raw bytes:

  1. 1 A PBM file always begins with a 2-byte magic number starting with 'P' (Hex: 50).
  2. 2 The second byte determines the encoding: '1' (Hex: 31) for plain ASCII text, and '4' (Hex: 34) for raw binary.
  3. 3 Following the magic bytes are whitespace-separated ASCII numbers defining the image's width and height. Unlike PGM and PPM formats, a PBM file does not include a 'maximum color value' parameter since it is strictly 1-bit.

Software Support

N
Netpbm (Command-line tools)
ImageMagick ImageMagick
GIMP GIMP
X
XnView

Conversion Tools

Share & Embed

Markdown Badge
PBM Format Badge
[![PBM Format](https://freewebptojpg.com/mime/image/pbm/badge.svg)](https://freewebptojpg.com/mime/image/pbm)
Interactive iframe Widget
<iframe src="https://freewebptojpg.com/mime/image/pbm/embed" width="100%" height="280" style="border:1px solid #cbd5e1;border-radius:8px;" title="PBM Specs"></iframe>

JSON API

All data on this page is available as a free, open JSON API. Use it in your project, documentation, or tooling.

GET https://freewebptojpg.com/mime/image/pbm.json Open JSON
Free to use
No auth required
CORS enabled
Use from any domain
Cached 24h
Cache-Control headers set

Frequently Asked Questions

What is a PBM file?

A PBM (Portable Bitmap) file is a highly simplified 1-bit monochrome raster image format. It is part of the Netpbm project and stores images purely as black and white pixels without any shades of gray or color.

Can I open a PBM file in a text editor?

Yes, if the PBM file was saved using the 'plain' ASCII encoding (indicated by the magic number 'P1'). When opened in a text editor, you will see a grid of '0's (white) and '1's (black) that roughly form the shape of the image.

Why is the PBM format still used?

Despite lacking compression, PBM's absolute simplicity makes it incredibly easy for developers to read, write, and manipulate programmatically. It is often used as a stepping stone or temporary intermediary format in complex command-line image processing or OCR (Optical Character Recognition) software.

Related Formats

Share this format