【问题标题】:Can I use Sharp image processing library in React js?我可以在 React js 中使用 Sharp 图像处理库吗?
【发布时间】:2021-12-17 04:04:55
【问题描述】:

我尝试在我的 create react 应用程序中使用 Sharp 图像处理。但它发送一个错误

这是我的代码

import sharp from 'sharp';

const buffer = await sharp(req.file.buffer)
          .resize({ width: 250, height: 250 })
          .extend({
            top: 10,
            bottom: 10,
            left: 10,
            right: 10,
            background:  '#d7d8de'
          })
          .png()

编辑:我使用的是 Node.js 版本 12.18.0

【问题讨论】:

    标签: javascript node.js reactjs image sharp


    【解决方案1】:

    No.

    Sharp 使用 node.js 运行时以及安装在主机系统上的二进制可执行代码。这一切都意味着 Sharp 不能在网络浏览器中运行。

    【讨论】:

    • 有没有类似的 react js 库?其实我喜欢夏普扩展选项。但是很多图像处理库中都没有这个选项。
    • React Native 怎么样?我们可以在 RN 中运行 Sharp.js 吗?
    猜你喜欢
    • 2020-10-27
    • 2012-06-29
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 2020-10-20
    • 1970-01-01
    • 2021-09-29
    • 2020-11-07
    相关资源
    最近更新 更多