@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
腾讯云对象储存图片处理
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" })
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" });
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 |