How to Extract Images from DOCX

This article was translated from English: Does it need improvement?
Translated
View the article in English

Extracting images from Word documents is a common requirement for content migration, media management, and programmatic document processing. IronWord simplifies access to embedded images, allowing them to be saved, reused, or analyzed through properties like dimensions and format.

The ExtractImages() function provides a simple and efficient way to retrieve all images from a document and access their metadata for further processing.

Get started with IronWord

今日あなたのプロジェクトでIronWordを無料トライアルで使用開始。

最初のステップ:
green arrow pointer


Extract Images Example

Extracting images from a Word document is straightforward with IronWord. The file "embedded_images.docx" will be used as an example file which includes 5 images on 3 different pages. The code snippet down below defines the core workflow for the image extraction process using the ExtractImages() method.

:path=/static-assets/word/content-code-examples/how-to/extract-images-properties.cs
using IronWord;

// Load an existing Word document
WordDocument doc = new WordDocument("embedded_images.docx");

// Extract all images from the document
var images = doc.ExtractImages();

// Iterate through extracted images
int count = 0;
foreach (var image in images)
{
    // Save each image to disk
    string fileName = $"extracted-image-{count}.png";
    image.SaveAs(fileName);

    Console.WriteLine($"Extracted image {count}:");
    Console.WriteLine($"Width: {image.Width}");
    Console.WriteLine($"Height: {image.Height}");
    Console.WriteLine($"Saved as: {fileName}");

    count++;
}

Console.WriteLine($"Total images extracted: {count}");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Sample File (embedded_images.docx)

Extract images from DOCX

Output

Output of extraction

The extracted images retain their original format (e.g., .jpg, .png, or other formats) and can be saved with appropriate file extensions. You can iterate through all images in the document or target specific sections based on your requirements.

よくある質問

IronWord の ExtractImages() 関数の主な機能は何ですか?

IronWord の ExtractImages() 関数は、Word 文書からすべての画像を取得し、そのメタデータにアクセスしてさらに処理するためのシンプルで効率的な方法を提供します。

IronWord を使用して DOCX ファイルから画像を抽出するにはどうすればよいですか?

IronWord を使用して DOCX ファイルから画像を抽出するには、IronWord ライブラリをダウンロードし、Word 文書を読み込み、ExtractImages() メソッドを使用して画像を抽出し、後で使用するためにディスクに保存します。

IronWord は抽出中に画像メタデータを処理できますか?

はい、IronWord を使用すると、抽出プロセス中に寸法や形式などの画像メタデータにアクセスできるため、さらに分析や処理を進める際に役立ちます。

IronWord を使用して抽出された画像ではどのようなファイル形式がサポートされていますか?

IronWord を使用して抽出された画像は、.jpg、.png などの元の形式が保持され、適切なファイル拡張子で保存できます。

IronWord を使用して Word 文書の特定のセクションから画像を抽出することは可能ですか?

はい、IronWord を使用すると、抽出プロセス中に、ドキュメント内のすべての画像を反復処理したり、要件に基づいて特定のセクションをターゲットにしたりすることができます。

IronWord を使用して画像を抽出するには、プログラミングの知識が必要ですか?

IronWord を使用して画像抽出のコードを実装するには、ExtractImages() などのメソッドを使用するため、特に C# の基本的なプログラミング知識が必要です。

IronWord での画像抽出を示すために使用されるサンプル ファイルは何ですか?

3 つの異なるページに 5 つの画像が含まれる「embedded_images.docx」というサンプル ファイルを使用して、IronWord での画像抽出プロセスを説明します。

Ahmad Sohail
フルスタックデベロッパー

Ahmadは、C#、Python、およびウェブ技術に強い基盤を持つフルスタック開発者です。彼はスケーラブルなソフトウェアソリューションの構築に深い関心を持ち、デザインと機能が実際のアプリケーションでどのように融合するかを探求することを楽しんでいます。

Iron Softwareチームに参加する前、Ahmadは自動化プロジェクトやAPI統合に取り組み、パフォーマンスの向上と開発者の体験向上に注力してきました。

彼の自由時間には、UI/UXのアイデアを試したり、オープンソースツールに貢献したり、時折テクニカルライティングやドキュメンテーションに取り組んで、複雑なトピックを理解しやすくすることを目指しています。

準備はいいですか?
Nuget ダウンロード 25,807 | バージョン: 2025.11 ただ今リリースされました