A gallery of picture formats

Before choosing a library the question is nearly always the same: will it read the pictures we already have? We read these four formats. JPEG, which is what a camera and a telephone produce. PNG, which is what a screenshot comes in, and what a logo with transparent parts comes in. BMP, the plain uncompressed one older software still writes. And TIFF, which is what a scanner and a fax machine write, whole batches of sheets at a time. Between them they cover what comes off a camera, off a screen, off a scanner and off an older machine, which is very nearly everything a working document is built from.

A list in a manual says what somebody meant to support rather than what happens when a real file off a real camera is handed over. So this page is the answer in the form that cannot flatter anybody: every picture the engine's own tests are run against, opened, and described by what came out of it rather than by what the example was told to expect — and between them those pictures cover all four formats. A file that declares nothing about itself says so, which is exactly why it is worth showing beside the ones that do.

What this example shows

  • The four formats read — JPEG, PNG, BMP and TIFF — all on one page.
  • Captions read back out of the image itself, never typed in.
  • Pictures that carry their own description, and one that leaves it to the page: both shown as they come.

The source code, complete

Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library. The third is the description itself: a plain list of what the page has to say, which is what the service is sent.

Read the Rust source Read the Python source Read the JSON source

The document itself

Open the document in English Open the document in French

A gallery of picture formats, first page

Optimised, this document weighs 87.8 kB — at least 50 % lighter than most PDF generators would write it

The document is lighter than it was, and every page still looks exactly the same. See this document's row in the table of every example.

Examples near this one

Images on a page

A photograph that goes in exactly as it came out of the camera, and one with transparent parts that keeps them, each on a page cut to its own size.

A picture fitted into a rectangle

One picture fitted into a rectangle of one size eight ways: three ways of sizing it, the same one stood in the top left corner with a 12-point inset, a quarter turn left, a quarter turn right, a turn of 20 degrees, and a left-to-right mirror — every panel drawing the picture at the place and the size the library worked out.

Two orders, one frame, one bottom edge

An order of four lines and one of seven, in frames of the same height, both ending on the same bottom edge. Underneath, two notes of unequal length whose lines are moved apart until each reaches the foot of its frame.

Code 128 and retail barcodes

Stripes for the two jobs that want them: Code 128 for any text at all, and the three a till reads — EAN-13, UPC-A, EAN-8 — each with its last digit worked out rather than typed.

Every example, by subject