You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5.8 MiB

This tool mix together two pictures taking their edges.

In [92]:
from PIL import Image, ImageChops, ImageFilter
from urllib.request import urlopen
In [93]:
pic1 = Image.open(r'2.png') #Pic from a file
In [94]:
pic1 = Image.open(urlopen('https://d7hftxdivxxvm.cloudfront.net/?resize_to=fit&width=480&height=640&quality=80&src=https%3A%2F%2Fd32dm0rphc51dk.cloudfront.net%2FoMDDSm77JFzMIYbi81xOaw%2Flarge.jpg')) #Pic from an url
In [95]:
pic2 = Image.open(r'2.png') #Pic from a file
In [96]:
pic2 = Image.open(urlopen('https://publicdelivery.b-cdn.net/wp-content/uploads/2020/01/Thomas-Ruff-Portrait-E.-Zapp-1990-scaled.jpg')) #Pic from an url
In [97]:
pic1 = pic1.convert("L").filter(ImageFilter.FIND_EDGES).filter(ImageFilter.Kernel((3, 3), (1, -3, -1, -1, 8, -1, 8, -1, -1), 1, 2)) #Create edges
pic2 = pic2.convert("L").filter(ImageFilter.FIND_EDGES).filter(ImageFilter.Kernel((3, 3), (9, -3, -1, -1, 8, -1, 8, -1, -1), 1, 10)) 
In [98]:
size1 = pic1.size
size2 = pic2.size

if size1 > size2: #make sizes of pics the same
    pic2 = pic2.resize(size1)
elif size2 > size1:
    pic1 = pic1.resize(size2)
In [99]:
pics = ImageChops.screen(pic1, pic2) #Mix the pics!
In [100]:
pics
Out[100]:
In [91]:
pics = pics.save('mix.jpg') #Save the mix
Out[91]:
In [ ]:
 
In [ ]: