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 🙏

© 2024 – Pkg Stats / Ryan Hefner

thumbor-es

v1.0.0

Published

TypeScript Thumbor client for Node, Deno, Bun, & browsers

Downloads

14

Readme

thumbor-es

TypeScript Thumbor client for Node, Deno, Bun, & browsers

JSR

TypeScript client for the Thumbor image service which allows you to build URIs in an expressive fashion using a fluent API.

This library is fully compatible with all JS runtimes (using the Web Cryptography API). It's heavily based on Square's Pollexor library for Java.

Documentation for the different options and filters can be found in the JSDoc and on JSR.

Installation

# deno
deno add jsr:@notwoods/thumbor-es

# npm
npm install thumbor-es

Examples

// Without encryption:
const url = await buildThumborUrl({ image: "http://example.com" });

// With encryption:
const url = await buildThumborUrl({ image: "http://example.com", key: "key" });
const url = await buildThumborUrl({
  image: "http://example.com/image.png",
  resize: { width: 48, height: 48 },
});
// Produces: /unsafe/48x48/example.com/image.png

const url = await buildThumborUrl({
  image: "http://example.com/image.png",
  crop: { top: 10, left: 10, bottom: 90, right: 90 },
  resize: { width: 40, height: 40 },
  smart: true,
});
// Produces: /unsafe/10x10:90x90/smart/40x40/example.com/image.png

const url = await buildThumborUrl({
  image: "http://example.com/image.png",
  crop: { top: 5, left: 5, bottom: 195, right: 195 },
  resize: { width: 95, height: 95 },
  align: { horizontal: "bottom", vertical: "right" },
});
// Produces: /unsafe/5x5:195x195/right/bottom/95x95/example.com/image.png

const url = await buildThumborUrl({
  image: "http://example.com/image.png",
  resize: { width: 200, height: 100 },
  filters: [
    roundCorner(10),
    watermark(
      await buildThumborUrl({
        image: "http://example.com/overlay1.png",
        resize: { width: 200, height: 100 },
      }),
    ),
    watermark(
      await buildThumborUrl({
        image: "http://example.com/overlay2.png",
        resize: { width: 50, height: 50 },
      }),
      { x: 75, y: 25 },
    ),
    quality(85),
  ],
});
// Produces: /unsafe/200x100/filters:round_corner(10,255,255,255):watermark(/unsafe/200x100/example.com/overlay1.png,0,0,0):watermark(/unsafe/50x50/example.com/overlay2.png,75,25,0):quality(85)/example.com/background.png

Comparison to other libraries

thumbor-es has a JavaScript-style API with an options object, unlike other older libraries using Java-style builder classes. It's also built with the latest browsers in mind, and is tinier, faster, and has 100% test coverage.