使用 Node.js 提取 PowerPoint 圖片 - 圖片提取器

需要從 PowerPoint 演示文稿中提取圖像以進行數據分析、歸檔或自動化嗎?GroupDocs.Parser Cloud SDK for Node.js 使開發人員可以使用簡單的 REST API 調用快速提取 .ppt.pptx 文件中的嵌入圖像。無需安裝 Office 或複雜的解析邏輯。

為什麼從 PowerPoint 中提取圖片?

  • 隔離視覺內容(標誌、圖示、圖表、照片)。
  • 將演示文稿存檔為結構化資產。
  • 啟用內容索引或計算機視覺工作流程。
  • 自動化從大量幻燈片中提取媒體。

在這篇文章中,我們將涵蓋以下主題:

PowerPoint 圖像提取 API

The GroupDocs.Parser Cloud SDK for Node.js 簡化了處理演示文稿文件的工作。它允許您:

  • 從特定或所有幻燈片中提取圖片。
  • 檢索結構化內容,例如幻燈片元數據或佈局。
  • 與其他格式合作 (Word, Excel, PDF, ZIP, 等等)。

前提條件

npm install groupdocs-parser-cloud
  • 有關客戶端憑證的更多信息,請訪問這篇 article

如何使用 Node.js 從 PowerPoint 中提取圖像

遵循這些步驟來使用 Node.js API 從 PowerPoint 簡報中開發您自己的圖像提取器:

步驟 1:初始化配置。

const { ParserApi, Configuration, ImagesRequest, FileInfo, ImagesOptions } = require("groupdocs-parser-cloud");

const config = new Configuration("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
const parserApi = new ParserApi(config);

步驟 2:設定檔案資訊和圖像選項。 初始化一個 ImagesRequest 類別的物件,並傳遞 ImagesOptions 類別的實例。

const fileInfo = new FileInfo();
// path to your PowerPoint file
fileInfo.filePath = "sample.pdf";

const options = new ImagesOptions();
options.fileInfo = fileInfo;

const request = new ImagesRequest(options);

步驟 3:從 PowerPoint 中提取圖像。 從 PowerPoint 簡報中提取圖片,請調用 images 方法。

parserApi.images(request).then((response) => {
    console.log("Images extracted successfully.");
    console.log(response.images);
}).catch((err) => {
    console.error("Failed to extract images:", err);
});
// 欲獲得更多示例,請訪問 https://github.com/groupdocs-parser-cloud/groupdocs-parser-cloud-node
const { ParserApi, Configuration, ImagesRequest, FileInfo, ImagesOptions } = require("groupdocs-parser-cloud");

const config = new Configuration("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
const parserApi = new ParserApi(config);

const fileInfo = new FileInfo();
// Path of input Powerpoint
fileInfo.filePath = "input.pptx";

const options = new ImagesOptions();
options.fileInfo = fileInfo;

const request = new ImagesRequest(options);

parserApi.images(request).then((response) => {
    console.log("Images extracted successfully.");
    console.log(response.images);
}).catch((err) => {
    console.error("Failed to extract images:", err);
});

您可以在下面的圖片中看到上述代碼示例的輸出:

從 PowerPoint 使用 cURL 擷取圖片

您也可以使用 GroupDocs.Parser REST API 和 cURL 提取圖像。

步驟 1 – 生成訪問令牌:

curl -X POST "https://api.groupdocs.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET" \
-H "Content-Type: application/x-www-form-urlencoded"

步驟 2 – 通過 REST API 提取圖像:

curl -v -X POST "https://api.groupdocs.cloud/v1.0/parser/images" \
-H  "accept: application/json" \
-H  "authorization: Bearer {ACCESS_TOKEN}" \
-H  "Content-Type: application/json" \
-d "{  \"FileInfo\": {    \"FilePath\": \"input.pptx\",    \"StorageName\": \"internal\"  },  \"OutputPath\": \"internal\",  \"StartPageNumber\": 1,  \"CountPagesToExtract\": 2}"
  • 將 替換為您生成的那個。

✅ 使用 cURL 的好處

  • Ideal for headless environments.
  • 適用於 CI/CD 管道的可編寫腳本。
  • 無需安裝 SDK。
  • 平台無關 (Linux/macOS/Windows)。

Free PowerPoint Image Extractor

不想寫程式碼?試試由 GroupDocs.Parser Cloud 提供的免費在線 PowerPoint Image Extractor

線上圖片提取器

結論

使用 GroupDocs.Parser Cloud SDK for Node.js,從 PowerPoint 文件中提取圖像變得快速且可擴展。無論您是在處理演示文稿檔案、AI 管道還是 CMS 整合——這個 REST API 讓您完全掌控視覺內容提取。

📚 其他資源

常見問題 – FAQs

Can I extract images from specific slides only?

  • 是的。您可以定義 StartPageNumber 和 CountPagesToExtract 以獲得精確控制。

圖像是否以原始分辨率返回?

  • 是的,API 提供嵌入在簡報中的原始品質圖像。

是否需要 PowerPoint 來運行這個?

  • 不。所有東西都在雲端運行,無需 MS Office。

是否提供免費試用?

  • 是的。新帳戶每月獲得 150 次免費 API 調用。如需更多信息,請訪問 pricing guide

相關文章