Skip to content

JavaScript client for generating imgproxy URL

License

Notifications You must be signed in to change notification settings

seanghay/imgproxy

 
 

Repository files navigation

@seanghay/imgproxy

Suppprts for ESM and CommonJS.

A Node client library to generate urls for imgproxy services.

This is a pure ESM/CommonJS fork of the original imgproxy.

Usage

npm i @seanghay/imgproxy

ESM

import { Imgproxy, Gravity } from '@seanghay/imgproxy';

const imgproxy = new Imgproxy({
  baseUrl: 'https://imgproxy.example.com',
  key: process.env.IMGPROXY_KEY,
  salt: process.env.IMGPROXY_SALT,
  encode: true,
});

imgproxy
  .builder()
  .resize('fill', 300, 200, 0)
  .gravity(Gravity.north_east)
  .dpr(2)
  .generateUrl('https://example.com/path/to/image.jpg');

CommonJS

const { Imgproxy, Gravity } = require('@seanghay/imgproxy');

const imgproxy = new Imgproxy({
  baseUrl: 'https://imgproxy.example.com',
  key: process.env.IMGPROXY_KEY,
  salt: process.env.IMGPROXY_SALT,
  encode: true,
});

imgproxy
  .builder()
  .resize('fill', 300, 200, 0)
  .gravity(Gravity.north_east)
  .dpr(2)
  .generateUrl('https://example.com/path/to/image.jpg');

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

This project is licensed under the MIT License.

About

JavaScript client for generating imgproxy URL

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • TypeScript 100.0%