Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/monke/mod.ts>Image

Color quantization and dithering in TypeScript.
Latest
class Image
implements ImageData
Re-export
import { Image } from "https://deno.land/x/monke@v1.0.2/mod.ts";

Image with width, height, and pixel data All methods mutate the image itself

Constructors

new
Image(
pixels: Uint8ClampedArray,
width: number,
height?: number,
)

Properties

channels: number

Canvas ImageData always returns RGBA values

colorSpace: "srgb"

We are only gonna work with sRGB images

readonly
data: Uint8ClampedArray

Get a Uint8ClampedArray with RGBA values

height: number
pixels: Color[]
width: number

Methods

blur(method: BlurType)

Blur the image. Currently only supports box blur.

dither(palette: Color[], options?: DitherOptions)

Recolor the image with dithering

grayscale(): void

Make the image grayscale

invert(): void

Invert colors in the image

map(fn: (c: Color) => Color): void

Apply a function on every pixel in the image

monochrome(dither?, ditherMode?: "floyd_steinberg" | "quick"): void

Recolor the image using just black and white

recolor(palette: Color[])

Recolor the image without dithering

Convert to an ImageData object