npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@refilelabs/image

v0.2.5

Published

Wasm-based image processing library developed by re;file labs

Readme

@refilelabs/image

NPM Version

A WebAssembly-powered library for advanced image manipulation and format conversion. This package provides tools for loading image metadata, converting images, and retrieving raw pixel data—all in the browser or Node.js environment.

It is used under the hood at re;file labs' image tools to power the different image processing features.

Installation

npm install @refilelabs/image

Features

  • Load image metadata
  • Retrieve raw RGBA pixel data and image properties
  • Convert images between different formats
  • Supports custom conversion settings

API Reference

loadMetadata(file: Uint8Array, src_type: string, cb: Function): Metadata

Loads the metadata of an image file.

Parameters:

  • file (Uint8Array): The image file to analyze.
  • src_type (string): The MIME type of the source image (e.g., image/png, image/jpeg).
  • cb (Function): A callback function to report progress.

Returns:

  • Metadata: An object containing image metadata (e.g., width, height, other information).

getPixels(file: Uint8Array, src_type: string): ImageData

Converts an image file to raw RGBA pixel data.

Parameters:

  • file (Uint8Array): The image file to convert.
  • src_type (string): The MIME type of the source image.

Returns:

  • ImageData: An object containing raw pixel data and image properties (e.g., width, height, color depth).

convertImage(file: Uint8Array, src_type: string, target_type: string, cb: Function, convert_settings?: Settings): Uint8Array

Converts an image from one format to another.

Parameters:

  • file (Uint8Array): The image file to convert.
  • src_type (string): The MIME type of the source image.
  • target_type (string): The target MIME type (e.g., image/webp, image/png).
  • cb (Function): A callback function to report progress.
  • convert_settings (Settings, optional): Settings for the conversion (e.g., for SVG).

Returns:

  • Uint8Array: The converted image data.

Interfaces

Metadata

Represents metadata of an image.

  • width (number): Image width.
  • height (number): Image height.
  • other (Record<string, string> | null): Additional metadata.

ImageData

Represents raw image data.

  • width (number): Image width.
  • height (number): Image height.
  • aspect_ratio (number): Aspect ratio.
  • color_depth (number): Color depth.
  • pixels (number[]): Raw RGBA pixel values.

SvgSettings

Settings specific to SVG format.

  • width (number): SVG width.
  • height (number): SVG height.

Settings

Settings for conversion.

  • type: "svg" for SVG settings.
  • Includes all properties of SvgSettings.

Usage Example

import init, { loadMetadata, getPixels, convertImage } from '@refilelabs/image';

await init();

const file = new Uint8Array(/* ... */);
const srcType = 'image/png';
const targetType = 'image/webp';

const metadata = loadMetadata(file, srcType, (progress) => console.log(`Progress: ${progress}%`));
console.log('Metadata:', metadata);

const imageData = getPixels(file, srcType);
console.log('Image Data:', imageData);

const converted = convertImage(file, srcType, targetType, (progress) => console.log(`Progress: ${progress}%`));
console.log('Converted Image:', converted);

Note: When using the library in a Node.js environment, you need to initialize the wasm module as follows (see issue):

const wasmBuffer = fs.readFileSync('node_modules/@refilelabs/image/image_bg.wasm')

await init(wasmBuffer)

License

MIT