@fengsi/imgproxy

2.1.1 • Public • Published

@fengsi/imgproxy

Using npm

npm install @fengsi/imgproxy

Require

import { Init, CryptographicInit } from "@fengsi/imgproxy";

const imgproxy = new Init("https://imgproxy.example.com"); // or const imgproxy = new CryptographicInit({ salt: process.env.IMGPROXY_SALT, key: process.env.IMGPROXY_KEY, baseUrl: "https://imgproxy.example.com" })

const url = imgproxy.getNewUrl({ url: "https://example.com/01.jpg", width: 250, height: 50, quality: 90, gravity: "ce", format: "webp" })

// https://imgproxy.example.com/pr:sharp/rs:fill:250:50:1/g:ce/q:90/LzAxLmpwZw.webp

// https://imgproxy.example.com/Oril43v9g8FpI0Y9oxkiulRVRuFZGlxehZ6_AD2Q-v0/rs:fill:250:50:1/g:ce/q:90/LzAxLmpwZw.webp

腾讯云对象储存图片处理

import { TencentInit } from "@fengsi/imgproxy";

const imgproxy = new TencentInit({ bucket: "bucketName-1250000000", region: "ap-shanghai", protocol: "https", key: "imageMogr2" })

const url = imgproxy.getNewUrl({ url: "https://example.com/gf/YYJdslldjjd.jpg", gravity: "so", width: 600, height: 50, quality: 70, format: "webp" })

// https://bucketName-1250000000.cos.ap-shanghai.myqcloud.com/gf/YYJdslldjjd.jpg?imageMogr2/crop/600x50/gravity/south/quality/70/format/webp

const imgproxy = new TencentInit({ baseUrl: "https://imgproxy.example.com" });

const url = imgproxy.getNewUrl({ url: "https://example.com/gf/YYJdslldjjd.jpg", gravity: "so", width: 600, height: 50, quality: 70, format: "webp" });

// https://imgproxy.example.com/gf/YYJdslldjjd.jpg?imageMogr2/crop/600x50/gravity/south/quality/70/format/webp

Default

Prop Type(s) Default
url String null(Don't empty)
width Number, String 0
height Number, String 0
format String auto
gravity String ce
quality Number,String 80
enlarge Number,String 1
resizing_type String fill

related articles

imgproxy

Readme

Keywords

Package Sidebar

Install

npm i @fengsi/imgproxy

Weekly Downloads

6

Version

2.1.1

License

ISC

Unpacked Size

28.9 kB

Total Files

3

Last publish

Collaborators

  • everyx