Skip to content
Emerging-PatternsPublic

About

Images for Bend 2

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ezimg

Images for Bend 2.

Install

ezimg is built and checked on bend 2.0.38.

With Bend alone there is no install step: import ezimg by its hub name and bend fetches it from the hub into ~/.bend/lib on the first run. emerging-ezimg@1.2.0.0 is ezimg v1.2.0:

import emerging-ezimg@1.2.0.0/main.bend as Img

That name resolves to 0x57618559b9b26dd8415f821176a3e692. To pin by content instead, import 0x57618559b9b26dd8415f821176a3e692/main.bend.

Or with ez, which records the package in ez.toml (ez init makes one):

ez add Emerging-Patterns/ezimg

Usage

A picture is a Raster: a width, a height, and row-major samples. Bend's own Image is the window quadtree, so a file image lives under this name. png_sig is the eight-byte PNG signature. parse_signature returns that signature when the bytes open with it, and none otherwise. decode_png returns a raster for an 8-bit PNG. decode_jpeg returns a raster for a baseline sequential JPEG, and none when the bytes are not one. encode_jpeg writes a baseline sequential 4:4:4 JPEG of the samples' colour, dropping alpha, and returns none for exactly the rasters encode_png refuses. Every sample is one U32 packed 0xAARRGGBB, whichever decoder returned it: a JPEG sample has alpha 255, and a gray JPEG sample repeats its level in R, G and B. width, height, size, count, and fill are the pixel helpers.

import emerging-ezimg@1.2.0.0/main.bend as Img

def main() -> U32:
  Img.width(Img.raster(2, 3, [0, 1, 2, 3, 4, 5]))

Compliance

LAWS.bend lists every behavior ezimg guarantees, one file under laws/ each, against ISO/IEC 15948 and the W3C PNG specification for PNG, and ISO/IEC 10918-1 | ITU-T T.81 with JFIF (ITU-T T.871) for JPEG. Each is proved by the file of the same name under proofs/ and checked by bend PROOF.bend (the first line must be ALL PROOFS CHECK). What ezimg trusts rather than proves, such as reading other encoders' files, is said on the code that assumes it. The plan and the audit behind them are in docs/rfc/ezimg-spec.md.

Scope today: PNG decode reads 8-bit colour types 0, 2, 3, 4 and 6 without interlace, and refuses anything else; PNG encode writes colour type 2 or 6. JPEG decode reads baseline sequential frames and refuses progressive and arithmetic ones; JPEG encode writes baseline 4:4:4. Full codec conformance is not claimed.

About

Images for Bend 2

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages