IRONSOFTWAREHOME

Extract Images from DOCX with C# using IronWord

Ahmad Sohail
Ahmad Sohail
Updated: August 2, 2026

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#
  1. 1Install IronWord with NuGet Package Manager

    PM > Install-Package IronWord

  2. 2Copy and run this code snippet.

    // Install IronWord: Install-Package IronWord
    using IronWord;
    using IronSoftware.Drawing;
    
    // 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)
    {
        // Cast to AnyBitmap to access SaveAs method
        ((AnyBitmap)image.Image).SaveAs($"output-{imageIndex}.png");
    
        // Access image properties
        Console.WriteLine($"Image {imageIndex}: {image.Width}x{image.Height}");
        imageIndex++;
    }
    C#
  3. 3Deploy to test on your live environment

    Start using IronWord in your project today with a free trial
    arrow pointer

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.

Get started with IronWord


How Do I Extract Images from a Word Document?

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 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 to remove any watermarks or restrictions.

using System;
using IronWord;
using IronSoftware.Drawing;

// 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";
    ((AnyBitmap)image.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}");

The ExtractImages method returns an enumerable collection of image objects, each containing the complete image data along with metadata. To save images, cast the Image property to AnyBitmap using ((AnyBitmap)image.Image).SaveAs() to access the SaveAs method. This requires adding using IronSoftware.Drawing; to your namespace declarations.

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 and original format. 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 can I extract images from a DOCX file using IronWord?

Using IronWord, you can extract images from a DOCX file by loading your Word document, calling the `ExtractImages()` method, and iterating over the resulting image collection to save each image to disk.

What are the steps involved in extracting images with IronWord?

To extract images with IronWord, first install IronWord, load your Word document, use the `ExtractImages()` method to get all embedded images, and then save the images to the desired format while accessing their properties like width and height.

Can I save extracted images in different formats with IronWord?

Yes, IronWord allows you to save extracted images in different formats. You can convert images to formats like JPEG, PNG, BMP, or GIF for your specific needs.

What metadata is accessible for images extracted from Word documents using IronWord?

When extracting images using IronWord, you have access to metadata such as image dimensions, format, and potentially other embedded information depending on the image.

Is it possible to process multiple Word documents simultaneously with IronWord for image extraction?

Yes, IronWord supports batch processing, allowing you to extract images from multiple Word documents simultaneously, which reduces processing time significantly.

How does IronWord handle high-resolution images or documents with numerous images during extraction?

IronWord supports memory management and asynchronous processing. This allows efficient handling of high-resolution images or documents with numerous images by using batch processing and `async/await` for I/O operations.

Can I filter which images to extract from a Word document using IronWord?

Yes, IronWord allows you to filter images based on their properties or document structure, enabling selective extraction of only the images you need.

How does IronWord integrate with content management systems for image extraction?

IronWord facilitates integration with content management systems by allowing extracted images to be used for creating previews, building galleries, or populating media libraries while linking them to document metadata.

What are some advanced scenarios supported by IronWord's image extraction capabilities?

IronWord's advanced image extraction capabilities include batch processing, image format conversion, and metadata preservation, which cater to complex production requirements like content migration and optimization workflows.

Are there licensing requirements for using IronWord in production environments?

Yes, IronWord requires appropriate licensing for production environments. It's crucial to apply license keys to remove any restrictions and consider extensions or upgrades for ongoing support and scalability.

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.

...
Read More

Ready to Get Started?

Nuget Downloads 56,401Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronWord
nuget.org/packages/IronWord/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronWord"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronWord to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronWord.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required