ItSolutionStuff.com

How to Add Image on Another Image in Python?

By Hardik Savani October 30, 2023
Python

Hi Artisan,

This article will provide an example of python add image to image. This post will give you a simple example of overlay an image on another image python. I would like to share with you how to add image into image in python. This post will give you a simple example of python add image on another image example.

Sometimes, we need to add image on an image and save it or share it with the customer, then I will give you a simple example of adding image on an image with python. we will use PIL library to add image on image. i will share with you two simple examples, one will simply add image on the image, and in another example, we will add image with a custom font family. so let's see both examples one by one.

Example 1:

You need to take the "sample.png" and "logo.png" images and put it in your root folder.

main.py

# Importing the PIL library
from PIL import Image, ImageDraw, ImageFilter
    
# Open an Image from Path
image1 = Image.open('sample.png')
image2 = Image.open('logo.png')
   
newImage = image1.copy()
newImage.paste(image2)
newImage.save('sample3.png', quality=95)

Output:

I hope it can help you...

Tags: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Write Text on Image in Python?

Read Now →

How to Convert JSON to String in Python?

Read Now →

How to Parse JSON Array in Python?

Read Now →

Convert JSON Array to Python List Example

Read Now →

Python Find and Replace String in JSON File Example

Read Now →

Python Search and Replace String in txt File Example

Read Now →

How to Find and Replace Text in a File in Python?

Read Now →

Python Generate Random Number Between 0 to 1 Example

Read Now →

How to Add Item in Dictionary Python?

Read Now →

Python Split String into List of Characters Example

Read Now →

Python Remove Empty String from List Example

Read Now →

Python List Remove Element by Index Example

Read Now →

How to Check if Today is Thursday or not in Python?

Read Now →