@fengsi/imgproxy
v2.1.1
Published
imgproxy
Downloads
14
Readme
@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
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