首页 > 解决方案 > 如何在 cloudinary [Node js] 中上传多个不同大小的图像

问题描述

例如,我希望上传一张不同尺寸的图片。image_1 是 1080x1080,我想以 200x200、500x500 和原始 1080x1080 等三个不同尺寸将其上传到 Cloudinary。

最后,我想得到三个不同大小图像的不同链接。

我去了文档,但没有发现任何与我的用例相似的东西

  await cloudinary.uploader.upload(
         imagePath, (err, result) => {
            if (err) {
              return res.status(400).json({
                error: "Failed to upload file",
              });
            }
            console.log(result)
          }
        );

到目前为止,我的代码上传了一张图片。

标签: node.jscloudinary

解决方案


您可以使用 Cloudinary 的响应式解决方案。您可以构建包含您想要指定的任何图像宽度或高度的动态图像 URL。这意味着您不必预先创建图像,并且您的图像可以根据需要动态调整大小。

欲了解更多信息:https ://cloudinary.com/documentation/responsive_images


推荐阅读