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 rather avoid building what I need for my use case from scratch.
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.
My main difficulty is in working with the legacy ole format (.doc, .xls, .ppt) as the new .***x format is just a zip file that can be dealt with easily in a programmatic fashion. The old format can be opened as a zip, but the images are stored in a stream called "Data", and they're mashed in there with other things, I can't just read "Data" as an image as the image header is ~250 bytes in.