使用 Node.js REST API 将 SVG 转换为 BMP

在本文中,您将学习如何使用 Node.js REST API 将 SVG 转换为 BMP。我们将按照以下章节中提到的详细步骤,使用 Node.js Low Code API 开发一个 SVG 到 BMP 的转换器。创建的应用程序可与 macOS、Windows 或 Linux 环境中支持的任何 Node.js 应用程序一起使用,并且转换过程免费。

先决条件

使用 Node.js REST API 将 SVG 转换为 BMP 的步骤

  1. 设置 API 的客户端 ID 和客户端密钥以将 SVG 转换为 BMP
  2. 使用用户凭证实例化 ImagingAPI 类以执行 SVG 到 BMP 的转换
  3. 指定源 SVG 和输出 BMP 文件名
  4. 访问并加载源 SVG 文件并将其上传到云存储
  5. 使用输入 SVG 文件流和输出 BMP 格式创建 ConvertImageRequest 实例
  6. 调用 图像转换 方法使用 Node.js REST API 将 SVG 转换为 BMP
  7. 将生成的BMP文件流保存在本地磁盘上

这些简单的步骤包括使用 Node.js Low Code API 将文件类型从 SVG 导出为 BMP。我们将使用 ImagingAPI 类的实例配置 SDK 来启动此过程。然后,我们将使用 FileStream 从磁盘访问源 SVG 文件,然后使用 ConvertImageRequest 类实例的 ConvertImage() 方法将其转换为 BMP。

Node.js Low Code API 中 SVG 到 BMP 转换的代码

这段简洁的示例代码演示了如何使用 Node.js Cloud API 将 SVG 转换为 BMP。完成必要的先决步骤后,您需要提供磁盘上源 SVG 图像的访问路径,并使用 Aspose.Imaging REST API SDK 将其渲染为 BMP。转换完成后,返回的 BMP 文件流将作为响应对象接收,您可以将其保存在本地磁盘上,也可以在所需的应用程序中使用该图像流。

In this article, we have explored to transform SVG to BMP with Cloud API. If you are interested in performing PNG to WEBP conversion, refer to the article on how to Convert PNG to WEBP with Node.js REST API.

 简体中文