您可以将此任务卸载到(无服务器)云功能,每个调整大小操作将在单独的 Docker 容器中运行,该容器在 HTTP 请求完成后立即关闭。
这是一个使用image-resizing
Node.js/NPM 包的示例:
$ npm install image-resizing --save
const { createHandler } = require("image-resizing");
module.exports.img = createHandler({
// Where the source images are located.
// E.g. gs://s.example.com/image.jpg
sourceBucket: "s.example.com",
// Where the transformed images needs to be stored.
// E.g. gs://c.example.com/image__w_80,h_60.jpg
cacheBucket: "c.example.com",
});
https://example.com/image.jpg
https://example.com/w_120,h_120,c_fill/image.jpg