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

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

先决条件

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

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

这些简单的步骤包括使用 Node.js Low Code API 将文件类型从 PNG 导出为 BMP。我们将首先使用 ImagingAPI 类的实例初始化 SDK。然后,我们将使用 FileStream 从磁盘访问源 PNG 文件,然后使用 ConvertImageRequest 类实例的 ConvertImage() 方法将其转换为 BMP。

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

这段简洁的示例代码演示了如何使用 Node.js Cloud API 将 *PNG 转换为 BMP。完成必要的先决步骤后,您需要提供访问磁盘上源 PNG 图像的路径,并使用 Aspose.Imaging REST API SDK 执行渲染为 BMP 图像的操作。转换完成后,您将收到生成的 BMP 图像文件流作为响应,然后您可以将其保存在本地磁盘上。

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

 简体中文