I'm looking for a tool that can extract detect and extract any image format from word documents in both .doc and .docx formats for an automatic document classification use case. It is nice to just detect the presence of images, but it infinitely more valuable to automatically carve the images out of the file through detecting the magic bytes and carving based on the file header.

I'm looking for something like oletools, but that toolkit doesn't support gathering images.

If there aren't any tools or libraries that satisfy my use case, then any libraries or tools that could support my own development of such a tool would be appreciated. Even research papers or articles on the theory behind such a tool, or even the doc/docx file format would be appreciated.

I would prefer python based tools, but I'll take what I can get. To be clear, I want a command line based tool, or a tool that can be added to a program or a script.


1 Answer 1


If I understand you correctly then for what you want to achieve you dont need any tools as word files are just archives. You can use your favourite unzip program and then you can find images in \word\media folder.

I dont know python but should be simple to unzip files and search for image files.

  • 1
    While that is true for modern files, it is not the case in legacy .doc files (that are ole files or Microsoft Compound files if you go by what Detect It Easy says). When I open this file type as an archive, it still works, but the image(s) are stored in the "Data" stream, with the header for the first picture stored ~ byte 240. I would need to carve the header out, read it, and appropriately carve the image out of the file based on the information in the header. If there's a tool for carving images out of data streams then that would work for me. I guess I have two different questions...
    – solumnant
    Jun 5, 2019 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.