misaon / imgproxy

๐Ÿ–ผ๏ธ Generate imgproxy url in browser and Node easily. Lightweight and Fast!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

๐Ÿ–ผ๏ธ @misaon/imgproxy

npm version npm downloads Github Actions Codecov

Generate imgproxy url in browser and Node easily. Lightweight and Fast!

Features

  • ๐Ÿ‘Œ  Zero configuration
  • ๐Ÿช„  Modern, tiny and tree shaken code
  • โš™๏ธ  Written in TypeScript
  • ๐Ÿ•’  Async-less methods and crypto computing
  • ๐Ÿš€  Browser and Node support
  • ๐Ÿ“ฆ  Extendable and customizable
  • ๐Ÿ“ฐ  Compatible with the latest version of imgproxy
  • ๐Ÿงช  Covered by tests >99%

Usage

Install package:

# npm
npm install @misaon/imgproxy

# yarn
yarn add @misaon/imgproxy

# pnpm
pnpm install @misaon/imgproxy

then in your code:

import { getImageUrl } from "@misaon/imgproxy";

const imageUrl = getImageUrl("https://example.com/my-image.jpg", {
  baseURL: "https://my-imgproxy.com", // optional
  secret: "imgproxy-secret-key",
  salt: "imgproxy-salt",
  modifiers: {
    width: "100",
    height: "75",
    // other modifiers... (see below)
  },
});

console.log(imageUrl);

That's all! ๐Ÿฅ‚


If you like use CommonJS, you can import like this:

const { getImageUrl } = require("misaon/imgproxy");

Modifiers

The list of modifiers that you can use is well typed and can be found here or in imgproxy docs.

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with ๐Ÿงก by @misaon

Published under MIT License.

About

๐Ÿ–ผ๏ธ Generate imgproxy url in browser and Node easily. Lightweight and Fast!

License:MIT License


Languages

Language:TypeScript 100.0%