Working with Images - Python .docx Module Last Updated : 21 Nov, 2022 Comments Improve Suggest changes Like Article Like Report Prerequisites: docx Word documents contain formatted text wrapped within three object levels. Lowest level- run objects, middle level- paragraph objects and highest level- document object. So, we cannot work with these documents using normal text editors. But, we can manipulate these word documents in python using the python-docx module. Python docx module allows user to manipulate docs by either manipulating the existing one or creating a new empty document and manipulating it. It is a powerful tool as it helps you to manipulate the document to a very large extend. To add an image in a word document we use add_picture() method. This method is used to add an image in your Word document whenever called. Syntax: doc.add_picture(image_path, width=None, height=None) Parameters: image_path: It is a string containing the path of the image to be added.width: It sets the width of the image to be added in the document.height: It sets the height of the image to be added in the document.In the function given above, height and width are not specified then the image appears in its native size. InstallationPip command to install this module is: pip install python-docxApproachImport moduleCreate docx objectDeclare add_picture() method wherever image is required to be inserted, along with the path to that image and dimensions(optional).Save document.Example 1: Adding an image in native size in a word document. Python3 # Import docx NOT python-docx import docx # Create an instance of a word document doc = docx.Document() # Add a Title to the document doc.add_heading('GeeksForGeeks', 0) # Image in its native size doc.add_heading('Image in Native Size:', 3) doc.add_picture('logo.png') # Now save the document to a location doc.save('gfg.docx') Output: gfg.docx Example 2: Adding an image in a defined size in a word document. Python3 # Import docx NOT python-docx import docx from docx.shared import Inches # Create an instance of a word document doc = docx.Document() # Add a Title to the document doc.add_heading('GeeksForGeeks', 0) # Image with defined size doc.add_heading('Image with Defined Size:', 3) doc.add_picture('logo.png', width=Inches(2), height=Inches(2)) # Now save the document to a location doc.save('gfg.docx') Output: gfg.docx Comment More infoAdvertise with us Next Article Working with Images - Python .docx Module aditya_taparia Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2020 Practice Tags : python Similar Reads Working with Images in Python PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. It was developed by Fredrik Lundh and several other contributors. Pillow is the friendly PIL fork and an easy to use library developed by Alex Clark and other contributors. Weâll be working with 6 min read Python Pillow - Working with Images In this article, we will see how to work with images using Pillow in Python. We will discuss basic operations like creating, saving, rotating images. So let's get started discussing in detail but first, let's see how to install pillow. Installation To install this package type the below command in t 4 min read Working with PDF files in Python All of you must be familiar with what PDFs are. In fact, they are one of the most important and widely used digital media. PDF stands for Portable Document Format. It uses .pdf extension. It is used to present and exchange documents reliably, independent of software, hardware, or operating system.In 8 min read Python | Working with the Image Data Type in pillow In this article, we will look into some attributes of an Image object that will give information about the image and the file it was loaded from. For this, we will need to import image module from pillow. Image we will be working on : size() method - It helps to get the dimensions of an image. IMG = 2 min read Python Pillow - Using Image Module In this article, we will see how to work with Image Module of PIL in Python. First, let's see how to install the PIL. Installation: Linux: On the Linux terminal type the following: pip install Pillow Installing pip via terminal: sudo apt-get update sudo apt-get install python-pipWorking with Image 5 min read Convert PDF to Image using Python Many tools are available on the internet for converting a PDF to an image. In this article, we are going to write code for converting pdf to image and make a handy application in python. Before writing the code we need to install the required module pdf2image and poppler.Modules Neededpdf2image 1.14 2 min read Docopt module in Python Docopt is a command line interface description module. It helps you define a interface for a command-line application and generates parser for it. The interface message in docopt is a formalized help message. Installation You can install docopt module in various ways, pip is one of the best ways to 3 min read Python PIL | Image.show() method PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, 1 min read Reading images in Python Python provides simple tools to work with images. Whether you're looking to open, view or save images there are many libraries to help. Let's see how to process the images using different libraries.1. Using ImageIO ImageIO is used for reading and writing images in various formats like PNG, JPEG, GIF 2 min read Adding Text on Image using Python - PIL In Python to open an image, image editing, saving that image in different formats one additional library called Python Imaging Library (PIL). Using this PIL we can do so many operations on images like create a new Image, edit an existing image, rotate an image, etc. For adding text we have to follow 2 min read Like