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

@immagin/client

v1.0.3

Published

Node.js and browser client for the Immagin image processing API

Readme

@immagin/client

Node.js and browser client for the Immagin image processing API.

Zero dependencies. Works everywhere fetch is available.

Install

npm install @immagin/client

Quick start

import { Immagin } from '@immagin/client'

const client = new Immagin({ apiKey: 'imk_...' })

// Generate a signed image URL (auto-fetches tenant credentials)
const url = await client.images.url('photos/hero.jpg', [
  { resize: { width: 800, height: 600 } },
])

// Upload an image (auto-detects MIME type)
import { readFileSync } from 'node:fs'
const buffer = readFileSync('photo.jpg')
await client.images.upload(buffer, 'photos/hero.jpg')

Images

Generate image URLs

Generate signed image URLs for serving processed images. All URLs are automatically signed — the signature locks transformation parameters so they can't be tampered with.

// Original image
const url = await client.images.url('photo.jpg')

// With transformations
const thumb = await client.images.url('photo.jpg', [
  { resize: { width: 800, height: 600 } },
  { text: { text: '© My Company', position: 'bottom-right', opacity: 0.5 } },
])

// Rotate, blur, grayscale
const edited = await client.images.url('photo.jpg', [
  { rotate: { angle: 90 } },
  { blur: 3 },
  { grayscale: true },
])

// Crop a region
const cropped = await client.images.url('photo.jpg', [
  { crop: { left: 100, top: 50, width: 400, height: 300 } },
])

// Flip, sharpen, adjust colors
const adjusted = await client.images.url('photo.jpg', [
  { flip: true },
  { sharpen: 2 },
  { modulate: { brightness: 1.2, saturation: 0.8 } },
])

// Disable auto-orient (enabled by default)
const raw = await client.images.url('photo.jpg', [
  { autoOrient: false },
  { resize: { width: 800 } },
])

// Custom output format (default is WebP at quality 90)
const jpeg = await client.images.url(
  'photo.jpg',
  [{ resize: { width: 800 } }],
  { format: 'jpeg', quality: 85 },
)

Note: url() uses node:crypto for signing and is intended for server-side use only. Tenant credentials are auto-fetched and cached on initialization.

Get a signed upload URL

Returns a CloudFront signed URL for direct upload (expires in 5 minutes). Useful for browser uploads where you don't want to expose your API key. The URL points to a CloudFront distribution (not S3 directly), so the underlying infrastructure is not exposed.

// Server: get the signed upload URL
const { uploadUrl, key } = await client.images.signUrl('photos/hero.jpg')
// Return uploadUrl to the browser

// Browser: upload directly
await fetch(uploadUrl, {
  method: 'PUT',
  body: file,
})

Upload (Node.js)

Convenience method that gets a signed URL and uploads in one call. The file goes directly to CloudFront/S3 and never passes through the API. MIME type is auto-detected from file bytes (magic bytes for JPEG, PNG, GIF, WebP, BMP, AVIF, HEIC, HEIF) or file extension.

import { readFileSync } from 'node:fs'

const buffer = readFileSync('photo.jpg')
await client.images.upload(buffer, 'uploads/photo.jpg')

List

const result = await client.images.list()
// { images: [{ key, size, lastModified }], nextCursor? }

// With pagination
const page = await client.images.list({
  prefix: 'uploads/',
  limit: 50,
  cursor: result.nextCursor,
})

Delete

await client.images.delete('uploads/photo.jpg')

Metadata

Inspect image properties (dimensions, format, color space, etc.) without downloading the full image. The request goes through Luna, which extracts metadata using Sharp.

const meta = await client.images.metadata('photo.jpg')
// {
//   width: 1920,
//   height: 1080,
//   format: 'jpeg',
//   space: 'srgb',
//   channels: 3,
//   hasAlpha: false,
//   density: 72,
//   isProgressive: false,
//   size: 204800,
// }

Note: metadata() uses node:crypto for signing and is intended for server-side use only.

API Keys

Manage API keys programmatically.

Create

const result = await client.keys.create({ name: 'Production' })
// { key: 'imk_...', prefix: 'imk_abcd', name: 'Production' }
// Save the key - it won't be shown again

List

const keys = await client.keys.list()
// [{ id, name, keyPrefix, createdAt, lastUsedAt }]

Revoke

await client.keys.revoke(keyId)

Error handling

All API errors throw ImmaginError with the HTTP status and response body.

import { Immagin, ImmaginError } from '@immagin/client'

try {
  await client.images.delete('missing.jpg')
} catch (err) {
  if (err instanceof ImmaginError) {
    console.log(err.status)  // 404
    console.log(err.message) // "Not found"
  }
}

Configuration

const client = new Immagin({
  apiKey: 'imk_...',              // Required
  baseUrl: 'https://...',         // Optional, defaults to https://gateway.immag.in
})

License

MIT