Python 3 Script to Overlay or Blend or Merge Transparent Logo Image with Another PNG Image Using Pillow Module Full Project For Beginners

 

Welcome folks today in this blog post we will be merging or overlaying or blending transparent logo image with another png image using pillow module in python 3.All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.py file and copy paste the following code

 

 

index.py

 

 

# import PIL module
from PIL import Image

# Front Image
filename = 'front.png'

# Back Image
filename1 = 'back.jpg'

# Open Front Image
frontImage = Image.open(filename)

# Open Background Image
background = Image.open(filename1)

# Convert image to RGBA
frontImage = frontImage.convert("RGBA")

# Convert image to RGBA
background = background.convert("RGBA")

# Calculate width to be at the center
width = (background.width - frontImage.width) // 2

# Calculate height to be at the center
height = (background.height - frontImage.height) // 2

# Paste the frontImage at (width, height)
background.paste(frontImage, (width, height), frontImage)

# Save this image
background.save("new.png", format="png")

Leave a Reply