from PIL import Image, ImageDraw img = Image.open('image.jpg') draw = ImageDraw.Draw(img) # starting and ending coordinates of the line x1 = 100 y1 = 200 x2 = 300 y2 = 400 # draw the line draw.line((x1, y1, x2, y2), fill='blue', width=5) img.show()In this example, we first open an image using the Image module of PIL. We then create an instance of the ImageDraw class by passing the opened image to it. We then define the starting and ending coordinates of the line and call the line() method of the ImageDraw class to draw the line on the image. Finally, we display the resulting image using the show() method of the Image class. 2. Drawing a rectangle: Draws a rectangular shape on an image. ```python from PIL import Image, ImageDraw img = Image.open('image.jpg') draw = ImageDraw.Draw(img) # coordinates of the top-left and bottom-right corners of the rectangle x1 = 100 y1 = 200 x2 = 300 y2 = 400 # draw the rectangle draw.rectangle((x1, y1, x2, y2), outline='red') img.show() ``` This example is similar to the previous one, but instead of drawing a line, we draw a rectangle using the rectangle() method of the ImageDraw class. We pass the coordinates of the top-left and bottom-right corners of the rectangle as a tuple to the method. We can also pass a fill parameter to fill the rectangle with a color. Both examples use the ImageDraw module of the Python Imaging Library (PIL).