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

@wasmedia/wlensfun

v0.3.0

Published

lensfun compiled to WebAssembly for browsers

Readme

wlensfun

lensfun compiled to WebAssembly — lens distortion, transverse chromatic aberration and vignetting correction in the browser, driven by lensfun's database of measured lens profiles.

Try it: lensfun.wasmedia.org — load a photo, pick the camera and lens, and correct it entirely in the browser.

Part of the wasmedia family of single-threaded + SIMD WASM ports that work on any site without COOP/COEP headers.

Install

npm install @wasmedia/wlensfun
npx wlensfun-fetch-db --out public   # download the lens profile database

The profile database is not bundled in the package. It is licensed CC BY-SA 3.0 rather than LGPL, upstream releases it independently of the library, and it is larger than the rest of the package combined. The CLI fetches it and repackages it for browsers as lensfun-db-v2.json.gz, written to --out <dir> (the current directory if omitted). Serve it alongside your app.

Usage

import { initWLensfun } from '@wasmedia/wlensfun';

const lf   = await initWLensfun();
const db   = await lf.loadDatabase('/lensfun-db-v2.json.gz');

const cam  = db.findCamera('Canon', 'Canon EOS 5D Mark III');
const lens = db.findLens(cam, null, 'Canon EF 24-70mm f/2.8L II USM');

const mod  = db.modifier(cam, lens, {
  focal: 35, aperture: 5.6, distance: 3,
  width: image.width, height: image.height,
});

const corrected = mod.apply(pixels);   // reusable across frames

mod.dispose();
db.dispose();

Both handles wrap raw pointers into WASM memory, so dispose() is not optional — nothing else frees them.

The database can also be loaded straight from lensfun's XML files — an OPFS directory in a worker, or a host directory under Node — with lf.loadDatabaseFiles(). It uses wopfs to read the files in place rather than copying them into memory.

Cameras match on their EXIF spelling first, then fuzzily, so both ('Canon', 'Canon EOS 5D Mark III') and wlibraw's ('Canon', 'EOS 5D Mark III') work. Lenses always match fuzzily.

From a raw file

examples/node/correct-raw.mjs decodes a camera raw with wlibraw, takes the camera, lens, focal length and aperture from its metadata, and corrects it in linear light:

npm run fetch-db
node examples/node/correct-raw.mjs photo.cr2      # add --lens "…" if the file records none

It writes photo.original.png and photo.corrected.png for comparison. Raw data is linear, so it corrects with colorSpace: 'linear'. wlibraw's decode() can't produce linear output yet (wlibraw#1), so the example gets it from LibRaw's dcraw_emu -4 through execute().

Frames shot in a crop mode (Nikon DX, 1:1, video crops) need --crop: the camera's crop factor describes its full sensor, and wlibraw doesn't yet report the 35 mm-equivalent focal length that would reveal the smaller frame (wlibraw#2). Pass the equivalent focal length over the real one, e.g. --crop 1.5 for DX on a full-frame body.

What it does

apply() runs every correction the lens has calibration data for, in lensfun's documented order: vignetting first, then distortion and TCA fused into a single resampling pass so the image is interpolated once rather than twice. Perspective correction and projection conversion are available through the corrections argument.

If you would rather resample yourself — on the GPU, say — coordinatesForRow() hands back the raw coordinate map instead.

Correction is CPU-bound and synchronous; @wasmedia/wlensfun/worker runs it off the main thread.

Documentation

Scope

wlensfun corrects; it does not decode. Raw handling belongs to wlibraw, format conversion to wvips and wimagemagick. This library takes and returns raw pixel buffers — 8-bit, 16-bit or 32-bit float, 3 or 4 channels.

License

LGPL-3.0-or-later, matching upstream lensfun. See LICENSE.

The lens profile database is separately licensed CC BY-SA 3.0 and carries its own attribution and share-alike obligations. It is fetched at build time rather than bundled, which keeps the two licenses distinct.