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

react-enhanced-image

v0.1.2

Published

React canvas image editor with stickers, pan, zoom and rotation

Readme

react-enhanced-image

React canvas image editor — pan, zoom, rotation, SVG/PNG stickers, mentions, locations and image export.

Installation

npm install react-enhanced-image
# or
pnpm add react-enhanced-image
# or
yarn add react-enhanced-image

Peer dependencies — install alongside the package:

npm install react react-dom zustand

Quick start

import { EnhancedImage, useStickers, useImageExporter } from 'react-enhanced-image'

function App() {
  const { addSticker, addMentionSticker, addLocationSticker } = useStickers('my-canvas')
  const { exportFinalImage } = useImageExporter('my-canvas')

  const handleExport = async () => {
    const result = await exportFinalImage()
    console.log(result?.dataUrl) // base64 PNG
  }

  return (
    <>
      <EnhancedImage
        id="my-canvas"
        image={imageDataUrl}
        cropWidth={600}
        cropHeight={600}
        zoom={100}
        rotation={0}
      />

      <button onClick={() => addMentionSticker('john')}>@john</button>
      <button onClick={() => addLocationSticker('Bratislava')}>📍 Bratislava</button>
      <button onClick={handleExport}>Export</button>
    </>
  )
}

API

<EnhancedImage />

| Prop | Type | Description | |------|------|-------------| | id | string | Unique canvas identifier — must match useStickers and useImageExporter | | image | string | Image source as data URL or HTTP URL | | cropWidth | number | Canvas width in pixels | | cropHeight | number | Canvas height in pixels | | zoom | number | Initial zoom level (100 = 100%) | | rotation | number | Initial rotation in degrees | | brightness | number | Initial brightness (0–200, 100 = default). Adjustable at runtime via useCanvas | | contrast | number | Initial contrast (0–200, 100 = default). Adjustable at runtime via useCanvas |

useStickers(canvasId)

const {
  stickers,                  // StickerInput[] | undefined — current stickers
  selectedSticker,           // string | undefined — selected sticker id
  addSticker,                // (svgString | dataUrl: string) => void
  addMentionSticker,         // (username: string) => void — renders @username pill
  addLocationSticker,        // (locationName: string) => void — renders 📍 location pill
  removeSticker,             // (id: string) => void
  setSelectedSticker,        // (id?: string) => void
  updateSticker,             // (sticker: StickerInput) => void
  updateAllStickers,         // (stickers: StickerInput[]) => void
  undo,                      // () => void
  redo,                      // () => void
  canUndo,                   // boolean
  canRedo,                   // boolean
  copySelectedSticker,       // () => void — copies selected sticker to clipboard
  pasteSticker,              // () => void — pastes clipboard sticker (+15px offset)
  duplicateSelectedSticker,  // () => void — duplicate in place (+15px offset)
} = useStickers('my-canvas')

useImageExporter(canvasId)

const { exportFinalImage } = useImageExporter('my-canvas')

const result = await exportFinalImage()

result is FinalImageResult | null:

type FinalImageResult = {
  dataUrl: string           // base64 PNG — the full rendered canvas (image + all stickers)
  metaData: {
    stickers: StickerInput[] // all stickers at time of export with their positions and sizes
  }
}

Use case — save & restore sticker positions:

// Export
const result = await exportFinalImage()
const flat = result.dataUrl          // send to server / display in <img>
const layout = result.metaData.stickers // save to DB to restore later

// Restore — pass stickers back via updateAllStickers
const { updateAllStickers } = useStickers('my-canvas')
updateAllStickers(layout)

StickerInput

type StickerInput = {
  id: string
  type: 'sticker' | 'mention' | 'location' | 'emoji'
  src: string        // data URL for images, username/location name for text types
  x: number
  y: number
  width: number
  height: number
  payload?: Record<string, unknown>
}

Sticker types

| Type | src value | Renders | |------|------------|---------| | sticker | SVG string or data URL (PNG/JPG) | Image on canvas | | mention | username without @ | @username dark pill | | location | location name | Red dot + location name dark pill | | emoji | emoji character or text | Text rendered directly |

Gestures

| Gesture | Action | |---------|--------| | Mouse drag | Pan image | | Mouse wheel | Zoom in/out | | Two-finger pinch | Zoom in/out (touch) | | Single finger drag | Pan image (touch) | | Click sticker | Select sticker | | Drag selected sticker | Move sticker | | Drag corner handle | Resize sticker |

Development

pnpm install
pnpm dev      # demo app at localhost:5173
pnpm build    # build library to dist/
pnpm lint

License

MIT