Lispex Images

Create an image from Lispex source, inspect it, restore the original bytes, and run the program.

Prepare the source

Install the Native CLI or npm package to use the lispex command. Save the following as heading-image.lspx in a new working folder. Use UTF-8 without a byte-order mark, LF line endings, and a final newline to reproduce the 115-byte example.

LISPEX
(define (place-heading lines-left)
  (if (< lines-left 2) 'next-page 'keep))
(display (place-heading 1))
(newline)

The rule returns next-page when fewer than two lines remain below the heading. The last two forms print the result and a newline.

1. Create the image

SH
lispex image encode --source heading-image.lspx --out heading-image.lspx.png

The command creates heading-image.lspx.png, prints nothing, and exits with status 0. This source fits on one page.

The encoder chooses the page count from the source and its structure. Use a name ending in .lspx.png for one page or .lspx-images.zip for several pages. If the suffix is wrong, the command stops before writing a file. For example, image-pageset-required asks you to change the output suffix to .lspx-images.zip.

2. Inspect the image

SH
lispex image inspect --image heading-image.lspx.png

The command checks the whole image, prints JSON, and exits with status 0. These lines from the output describe the example.

  "source_bytes": 115,
  "node_count": 24,
  "max_depth": 3,
  "page_count": 1,

The JSON also contains format and profile identifiers, source_id, and SHA-256 hashes used to check integrity. It reports these values without printing the source. Different line endings change the source bytes and their identifiers.

3. Restore the source

SH
lispex image decode --image heading-image.lspx.png --out recovered.lspx

The command creates recovered.lspx with the same 115 bytes as the original file. It prints nothing and exits with status 0. Open the file to read the four lines shown above.

Both encode and decode preserve existing output files. Choose a new output name if the file already exists.

4. Run the image

SH
lispex run --image heading-image.lspx.png

The command prints.

next-page

It exits with status 0. Before running, it fully decodes and checks the image, including rebuilding it to compare every byte. Only then does it pass the restored source to the interpreter.

Use the Playground

The Playground handles image files locally in your browser.

ActionResult
Create imageBuilds an image from the current editor contents
Open imageChecks a local PNG or ZIP before showing a preview
Change pageShows a PNG page from the fully checked image
Recover sourceReplaces the editor contents without running the program
Download imageSaves the image file
Run imageChecks the image and runs its source as a separate action

Native and npm provide the same file commands. The public WASM build exposes the same Rust image operations for embedding. The Playground uses these operations for its local file controls.

Share the original file

Send the original PNG or the complete ZIP. For several pages, use the ZIP as the input to inspect, decode, or run --image.

Screenshots, resizing, color conversion, added metadata, recompression, missing pages, and reordered pages are rejected. The decoder reads the exact file bytes. It does not use OCR or camera recognition.

Use the source with Vouch

An image carries readable source data. Lispex Vouch handles producer authentication, recipient trust policy, request binding, re-execution, and the local decision to accept a result.

Use --source-image to supply an image as Vouch's source. The command first checks the whole image. Native accepts it for source identity, policy creation, issuance, inspection, authenticated verification, re-execution, and gates. npm accepts it for source identity, policy creation, and authenticated verification. The recipient supplies the exact input and applies the authorization rules bound to that request.

Image Format and Safety · Lispex Vouch overview · Run Lispex in Your Application