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

romaine

v0.12.0

Published

React OpenCV Manipulation and Image Narration & Editing

Readme

romaine

React OpenCV Manipulation and Image Narration / Editing

Installation

npm i romaine
# or
yarn add romaine

Quick Features

  • Image Cropping (regular & perspective)
  • Image Rotation
  • Image Flipping (horizontal & vertical)
  • Image Scaling
  • Background Removal (GrabCut via OpenCV.js)
  • Brush-based background refinement
  • Undo / Full Reset history
  • PNG & JPEG export with alpha-to-white blending
  • Plugin architecture for extensible commands (e.g. @romaine-plugins/bg-remover)

Example

See romaine-components for a ready-made toolbar, or build your own UI using the hooks and canvas API.

import { Romaine } from "romaine";
import { Canvas, useRomaine } from "romaine";

function App() {
  return (
    <Romaine>
      <MyEditor />
    </Romaine>
  );
}

function MyEditor() {
  const { setMode, loaded } = useRomaine();
  return loaded ? (
    <Canvas image="/photo.jpg" maxWidth={800} maxHeight={600} />
  ) : null;
}

Romaine Props

| Parameter | Type | Description | Default | Context Alternative | | :-------- | :------- | :--------------------------- | :------ | :------------------ | | angle | number | Turn angle for rotation tool | 90 | setAngle(90) |

Canvas Props

| Parameter | Type | Description | Default | | :---------- | :---------------------- | :-------------------------------- | :---------- | | image | string \| File \| null | Image source (URL, File, or null) | null | | maxWidth | number | Max preview width in pixels | — | | maxHeight | number | Max preview height in pixels | — | | pointSize | number | Crop point handle size | 5 | | lineWidth | number | Crop border line width | 1 |

Exporting

Use a ref on <Canvas> to access export methods:

const ref = useRef<RomaineRef>(null);

// Export as blob
const blob = await ref.current?.getBlob({
  type: "image/jpeg",
  quality: 0.85,
  maxSize: { width: 1920, height: 1080 },
  jpeg: { transparentToWhite: true },
});

// Export as data URL
const dataURL = await ref.current?.getDataURL({
  type: "image/png",
  maxSize: { width: 1920, height: 1080 },
});

ImageExportOptions

| Parameter | Type | Description | | :--------- | :--------------------------------------------------- | :----------------------------------------------------------------------------------------------------------- | | type | "image/png" \| "image/jpeg" \| "image/webp" \| "keep-same" | Output format. "keep-same" preserves the original file type. | | quality | number | 0–1 quality for lossy formats (JPEG default 0.92, WebP default 0.80). | | maxSize | { width: number; height: number } | Maximum export dimensions. If the image exceeds either dimension, it is downscaled proportionally to fit. |

getBlob also accepts a jpeg.transparentToWhite option to alpha-blend transparent pixels against white before JPEG export.

Note: maxSize only affects the exported output — it does not modify the working image. Use the scale mode for permanent resizing.

Plugin Architecture

Romaine supports extensible commands via the (string & {}) union on RomaineCommands. Plugins can:

  • Use canvasApi ref on the context to read/write the preview canvas
  • Call pushHistory(customPayload?) to integrate with undo
  • Register custom modes that are handled by plugin overlay components rendered as children of <Canvas>

See @romaine-plugins/bg-remover for a reference plugin implementation.

Versioning

Currently minor changes may be breaking until a stable 1.0.0 release. Semantic versioning will be used post stable release.

Special Thanks

@Giacomocerquone publisher of react-perspective-cropper (MIT)

@opencv creators of computer vision software this package relies on (3-clause BSD)