Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ const imageWithWarnings = await Image.decode(data, {
```

**Note:** When using `Image.decode()`, the library automatically tries runtime-optimized decoders
(ImageDecoder API) first, falling back to the pure JS decoder with tolerant mode for maximum
compatibility.

Comment thread
Hexagon marked this conversation as resolved.
## CMYK Color Space Support

Expand Down Expand Up @@ -378,9 +380,6 @@ const roundtrip = await Image.decode(parsed.bytes, "png");
console.log(roundtrip.width, roundtrip.height);
```

(ImageDecoder API) first, falling back to the pure JS decoder with tolerant mode for maximum
compatibility.

## Fault-Tolerant Decoding for Other Formats

In addition to JPEG, @cross/image provides fault-tolerant decoding for several other formats that
Expand Down
45 changes: 45 additions & 0 deletions docs/src/examples/decoding-encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,51 @@ const pcx = await image.encode("pcx");
await Deno.writeFile("output.pcx", pcx);
```

### QOI (Quite OK Image)

Fast lossless format with simple encoding.

```ts
import { Image } from "jsr:@cross/image";

const data = await Deno.readFile("input.png");
const image = await Image.decode(data);

// Encode as QOI
const qoi = await image.encode("qoi");
await Deno.writeFile("output.qoi", qoi);
```

### PGM (Portable GrayMap)

Netpbm grayscale format; RGB is converted to grayscale using luma weighting.

```ts
import { Image } from "jsr:@cross/image";

const data = await Deno.readFile("input.png");
const image = await Image.decode(data);

// Encode as PGM (binary P5 format)
const pgm = await image.encode("pgm");
await Deno.writeFile("output.pgm", pgm);
```

### PBM (Portable BitMap)

Netpbm monochrome format; pixels at or above luma 128 become white.

```ts
import { Image } from "jsr:@cross/image";

const data = await Deno.readFile("input.png");
const image = await Image.decode(data);

// Encode as PBM (binary P4 format)
const pbm = await image.encode("pbm");
await Deno.writeFile("output.pbm", pbm);
```

## Format Conversion Examples

### PNG to JPEG
Expand Down
7 changes: 4 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ await Image.decode(bytes, "png");

## Supported Formats

@cross/image supports 15 image formats with varying levels of pure-JS implementation:
@cross/image supports 18 image formats with varying levels of pure-JS implementation:

- **PNG, APNG, BMP, ICO, GIF, DNG, PAM, PPM, PCX, ASCII** - Full pure-JS implementation
- **PNG, APNG, BMP, ICO, GIF, DNG, PAM, PPM, PGM, PBM, PCX, QOI, ASCII** - Full pure-JS
implementation
- **JPEG** - Pure-JS baseline & progressive DCT
- **WebP** - Pure-JS lossless, native API for lossy VP8
- **TIFF** - Pure-JS uncompressed + LZW, native API for other compressions
- **TIFF** - Pure-JS uncompressed, LZW, PackBits & Deflate; native API for JPEG compression
- **HEIC, AVIF** - Runtime-based implementation (requires ImageDecoder/OffscreenCanvas API)

See the [Format Support](formats.md) page for detailed compatibility information.
Expand Down
Loading