Extract Images from DOCX with C# / IronWord

Extracting images from Word documents is a common requirement when it comes to content migration, media management, and programmatic document processing. IronWord eases access to embedded images which can then be saved, reused, or analyzed through properties such as dimensions and format.

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

Get started with IronWord

Start using IronWord in your project today with a free trial.

First Step:
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 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) and can be saved with correct file extensions. Image iteration can span the entire document or focus on specific sections, driven by entity-level requirements such as individual or enterprise use cases.

Frequently Asked Questions

What is the main functionality of the ExtractImages() function in IronWord?

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

How can I start extracting images from DOCX files using IronWord?

To start extracting images from DOCX files using IronWord, download the IronWord library, load the Word document, use the ExtractImages() method to extract images, and save them to disk for further use.

Can IronWord handle image metadata during extraction?

Yes, IronWord allows you to access image metadata such as dimensions and format during the extraction process, which can be useful for further analysis or processing.

What file formats are supported for extracted images using IronWord?

The images extracted using IronWord retain their original format, such as .jpg, .png, or other formats, and can be saved with appropriate file extensions.

Is it possible to extract images from specific sections of a Word document using IronWord?

Yes, with IronWord, you can iterate through all images in the document or target specific sections based on your requirements during the extraction process.

Do I need programming knowledge to use IronWord for extracting images?

Basic programming knowledge, particularly in C#, is required to implement the code for image extraction using IronWord as it involves using methods like ExtractImages().

What is an example file used to demonstrate image extraction in IronWord?

An example file named 'embedded_images.docx', which includes 5 images on 3 different pages, is used to demonstrate the image extraction process in IronWord.

Ahmad Sohail
Full Stack Developer

Ahmad is a full-stack developer with a strong foundation in C#, Python, and web technologies. He has a deep interest in building scalable software solutions and enjoys exploring how design and functionality meet in real-world applications.

Before joining the Iron Software team, Ahmad worked on automation projects ...

Read More
Ready to Get Started?
Nuget Downloads 26,559 | Version: 2025.11 just released