Extract Images from DOCX with C# / IronWord

IronWord’s ExtractImages() method enables you to programmatically extract all embedded images from Word documents, providing access to image data and metadata like dimensions and format for saving or processing.

Quickstart: Extract Images from DOCX in C#

```csharp {title="Quick Image Extraction Example"} // Install IronWord: Install-Package IronWord using IronWord;

// Load your Word document WordDocument doc = new WordDocument("document.docx");

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

// Save each image with custom naming int imageIndex = 0; foreach (var image in images) { // Save to specified format image.SaveAs($"output-{imageIndex}.png");

// Access image properties
Console.WriteLine($"Image {imageIndex}: {image.Width}x{image.Height}");
imageIndex++;

}


Extracting images from Word documents is a common requirement for content migration, media management, and programmatic document processing. Whether you're building a content management system, automating document workflows, or creating digital archives, 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. This method returns a collection of image objects that contain both the raw image data and useful metadata properties. For developers working with [PowerPoint presentations](https://ironsoftware.com/csharp/ppt/examples/create-empty-presentation/), similar functionality exists in other Iron libraries, demonstrating a consistent API design across the product suite.

### How Do I Get Started with IronWord?

---

<div class="hsg-featured-snippet">
    <h2>How to Extract Images from DOCX</h2>
    <ol>
        <li>Download a C# library for extracting images from DOCX</li>
        <li>Load an existing Word document</li>
        <li>Access and extract image content using <code>ExtractImages</code></li>
        <li>Save extracted images to disk</li>
        <li>Process or export the image files</li>
    </ol>
</div>

## How Do I Extract Images from a Word Document?

<!-- TODO: Add image here -->
<!-- ![Diagram illustrating extract images example implementation](/static-assets/images/TODO/extract-images-example-code_illustration.webp) -->
<!-- Description: Diagram or screenshot illustrating the code concept -->

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 below defines the core workflow for the image extraction process using the `ExtractImages()` method.

When working with document processing libraries, it's essential to understand [licensing requirements](https://ironsoftware.com/csharp/ppt/licensing/) to ensure your application complies with usage terms. IronWord follows similar licensing patterns to other Iron products, offering perpetual licenses with comprehensive support options. For production deployments, you'll need to apply [license keys](https://ironsoftware.com/csharp/ppt/get-started/license-keys/) to remove any watermarks or restrictions.

```csharp
:path=/static-assets/word/content-code-examples/how-to/extract-images-properties.cs

The ExtractImages() method returns an enumerable collection of image objects, each containing the complete image data along with metadata. This approach allows for flexible processing workflows—you might save images to disk as shown above, convert them to different formats, or stream them directly to cloud storage services. The method handles various image formats commonly embedded in Word documents, including JPEG, PNG, BMP, and GIF.

What Does the Sample Document Look Like?

Word document with embedded images: Google logo, head silhouettes, galaxy scene, lion, and zen stones

What Output Should I Expect?

Debug console showing 5 extracted images with dimensions and filenames extracted-image-0.png through extracted-image-4.png

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.

Advanced Image Extraction Scenarios

Beyond basic extraction, IronWord’s image handling capabilities support several advanced scenarios that developers frequently encounter in production applications:

Batch Processing Multiple Documents: When processing large document collections, you can implement parallel processing to extract images from multiple Word files simultaneously. This approach significantly reduces processing time for document archives or content migration projects.

Image Format Conversion: The extracted image objects support conversion between formats. You might extract a JPEG from a Word document and save it as a PNG for web optimization, or convert to WebP for modern browser compatibility.

Metadata Preservation: Each extracted image retains important metadata including dimensions, resolution, and color depth. This information proves valuable when implementing image optimization pipelines or maintaining quality standards across your application.

For enterprise applications requiring ongoing support and regular updates, consider exploring license extensions that provide continued access to new features and priority support. If your project scope expands, upgrade options allow seamless scaling to cover additional developers or deployment locations.

Integration with Document Workflows

Image extraction often forms part of larger document processing workflows. Consider these common integration patterns:

Content Management Systems: Extract images during document upload to create thumbnail previews, build image galleries, or populate media libraries. The extracted images can be indexed for search functionality or tagged with document metadata.

Document Conversion Pipelines: When converting Word documents to other formats, extracted images can be processed separately for optimal quality. This separation allows format-specific optimization—for example, applying different compression settings for web versus print output.

Quality Assurance Workflows: Automated extraction enables systematic review of embedded images for compliance with brand guidelines, resolution requirements, or file size constraints. You can flag documents containing low-resolution images or incorrect formats before publication.

To stay updated with the latest features and improvements in document processing capabilities, check the product changelog regularly. New releases often include performance enhancements and expanded format support that can benefit your image extraction workflows.

Performance Considerations

When working with documents containing numerous or high-resolution images, consider these performance optimization strategies:

Memory Management: Process images in batches rather than loading all images into memory simultaneously. This approach prevents memory exhaustion when dealing with large documents or high-resolution images.

Asynchronous Processing: Implement async/await patterns for I/O operations, especially when saving extracted images to disk or network storage. This keeps your application responsive during lengthy extraction operations.

Selective Extraction: If you only need specific images, consider implementing filters based on image properties or document structure to avoid processing unnecessary content.

The robust API design ensures consistent behavior across different document types and image formats, making it straightforward to build reliable image extraction features into your .NET applications.

Frequently Asked Questions

How do I extract images from a DOCX file in C#?

You can extract images from DOCX files using IronWord's ExtractImages() method. Simply load your Word document with WordDocument doc = new WordDocument("document.docx"), then call doc.ExtractImages() to retrieve all embedded images. Each image can be saved using the SaveAs() method with your preferred format and filename.

What image properties can I access when extracting images from Word documents?

IronWord provides access to important image metadata including Width and Height dimensions. The ExtractImages() method returns a collection of image objects that contain both raw image data and these metadata properties, allowing you to programmatically analyze or process images based on their characteristics.

Can I save extracted images in different formats?

Yes, IronWord allows you to save extracted images in various formats. Use the SaveAs() method on each image object and specify your desired filename with the appropriate extension (e.g., .png, .jpg). The library handles the format conversion automatically based on the file extension you provide.

How do I install the library for extracting images from Word documents?

Install IronWord via NuGet Package Manager using the command: Install-Package IronWord. Once installed, add 'using IronWord;' to your C# file to access the image extraction functionality and other document processing features.

Is it possible to extract images from multi-page Word documents?

Yes, IronWord's ExtractImages() method extracts all images from the entire Word document regardless of how many pages it contains. The method returns a complete collection of all embedded images found throughout the document, whether they're on one page or spread across multiple pages.

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 29,064 | Version: 2025.12 just released