Free PBM test files and sample generator
A Netpbm 1-bit black-and-white image. Generate valid .pbm sample files for testing image converters, OCR tooling and pipelines.
What is a .pbm file?
PBM: Portable Bitmap Image. PBM is a pure black-and-white Netpbm bitmap with one bit per pixel, packed eight to a byte. Bit-level packing is exactly the kind of detail a loader can get subtly wrong.
Why generate a test PBM file?
- Test bit-packed image parsing in your own loader.
- Exercise OCR or fax-style monochrome pipelines.
- Verify conversion from 1-bit to grayscale or color.
What you can put inside a .pbm file
You get 2 content options for PBM, so the file holds something meaningful rather than random padding: Solid color, Checkerboard. For PBM these are alternatives, so choose the one that matches what you need to test.
How a .pbm file is identified
Every .pbm file begins with 50 34, "P4", binary bitmap Netpbm, one bit per pixel. That is what a validator inspecting content rather than the file name looks for.
How the size lands on the exact byte
Header comment lines absorb the remainder; the height carries the bulk of the size.
Negative testing with broken PBM files
- Invalid. Identifiable, but wrong inside, so it fails during parsing.
- Corrupted. The leading bytes are destroyed, so the
50 34identifying a .pbm is gone. Same length as the valid file. - Incomplete. Truncated part-way, so it is genuinely shorter.
- Empty. Chosen under Content rather than File Condition: valid structure, no data.
Which failure to reach for, and what to assert for each, is covered in how to make a corrupted file for testing. For upload limits and type checks see testing file upload validation.
Sample PBM content
[PBM], P4 binary Netpbm: magic, width/height, packed 1-bit pixels.
This shows the shape of the file. Your download is generated fresh at the size you choose, so the values will differ.
How to open and verify the file
Open in GIMP or IrfanView; convert with `pbmtopng` or ImageMagick.
Media type image/x-portable-bitmap · extension .pbm · category Images
Generate a .pbm file → · questions about sizes, privacy or cost are answered on the site FAQ.
Frequently asked questions about PBM files
What identifies a .pbm file?
A .pbm file begins with the bytes 50 34, "P4", binary bitmap Netpbm, one bit per pixel. Those bytes are what a content-sniffing validator looks for, and what the Corrupted condition destroys.
How can a .pbm file be an exact number of bytes?
Header comment lines absorb the remainder; the height carries the bulk of the size.
What can go inside the PBM file?
There are 2 content options for .pbm: Solid color, Checkerboard. For PBM these are alternatives, so pick the one matching what you need to test.
Can I download several broken PBM files at once?
Yes, select more than one File Condition and you get one ZIP containing a .pbm per condition, each named after its condition.
Can the PBM file use UTF-16 or a byte-order mark?
No, and deliberately. A .pbm file is a container rather than plain text, so rewriting its bytes as UTF-16 would not produce a UTF-16 document. It would produce a broken file. Use a text format such as CSV, JSON or XML for encoding tests.
How do I open or verify the PBM file?
Open in GIMP or IrfanView; convert with pbmtopng or ImageMagick.