Skip to main content
Home

@img/png@0.1.6
Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score100%
Downloads127/wk
Published5 months ago (0.1.6)

A image encoder/decoder for the PNG format

This is a TypeScript implementation of the PNG image format. The module offers encoding and decoding abilities. The raw pixel format/ the decoded format is a repeating sequence of [ r, g, b, a ] in a Uint8Array, or Uint8ClampedArray.

This implementation is based off the PNG Specification.

Examples

Example 1

import { encodePNG } from "@img/png";

await Deno.mkdir(".output/", { recursive: true });

const rawData = await new Response(ReadableStream.from(async function* () {
  for (let r = 0; r < 256; ++r) {
    for (let c = 0; c < 256; ++c) {
      yield Uint8Array.from([255 - r, c, r, 255]);
    }
  }
}())).bytes() as Uint8Array<ArrayBuffer>;

await Deno.writeFile(".output/mod.png", await encodePNG(rawData, {
  width: 256,
  height: 256,
  compression: 0,
  filter: 0,
  interlace: 0,
}));
Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@img/png

Import symbol

import * as png from "@img/png";
or

Import directly with a jsr specifier

import * as png from "jsr:@img/png";

Add Package

pnpm i jsr:@img/png
or (using pnpm 10.8 or older)
pnpm dlx jsr add @img/png

Import symbol

import * as png from "@img/png";

Add Package

yarn add jsr:@img/png
or (using Yarn 4.8 or older)
yarn dlx jsr add @img/png

Import symbol

import * as png from "@img/png";

Add Package

vlt install jsr:@img/png

Import symbol

import * as png from "@img/png";

Add Package

npx jsr add @img/png

Import symbol

import * as png from "@img/png";

Add Package

bunx jsr add @img/png

Import symbol

import * as png from "@img/png";