Search code examples
pythonsoftware-design

Is there a way in python to write a image to a word file?


I have a sample image of a graph that is extracted from an excel file using a win32 package of python.

The implementation of the above is solved in this question = extracting graphs as images from excel

Now, I want to read an image in python and write it to a doc file and save it. which ultimately gives me an output of somethig like this

sample output


Solution

  • You can use the add_picture()-method of the following library:

    python-docx

    This also gives you options for resizing and placement.