Skip to content

ascorbic/get-pixels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒˆ ๐Ÿฆ•@unpic/pixels

Load and decode the pixels for a PNG or JPEG image

This module will take the raw data or URL of a PNG or JPEG image and return the decoded pixels and dimensions of the image.

โš ๏ธ If you have previously installed this via deno.land/x, please switch to using JSR. โš ๏ธ

Usage

import { getPixels } from "jsr:@unpic/pixels";

// From a URL
const { width, height, data } = await getPixels(
	"https://placecats.com/100/100",
);

// From a file

const file = await Deno.readFile("kitten.png");

const { width, height, data } = await getPixels(file);

There is also a getFormat function that will return the format of the image data. This is detected by the first magic bytes at the start of the data.

import { getFormat } from "jsr:@unpic/pixels";

const file = await Deno.readFile("kitten.png");
const format = getFormat(file);
// format === "png"

License

ยฉ 2023-2024 Matt Kane. This project is MIT licensed.

About

๐ŸŒˆ ๐Ÿฆ• Get the decoded pixel data from a JPG or PNG image

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •