Created
March 31, 2021 01:28
-
-
Save symisc/68eb28b2157c52ffbd649738f1a180e8 to your computer and use it in GitHub Desktop.
Composite two or more images on top of another using the PixLab API - https://pixlab.io/cmd?id=merge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
# Composite two smiley on top of the famous Michael jordan crying face. | |
# A more sophisticated approach would be to extract the facial landmarks coordinates using /facelandmarks and composite something on the different regions. | |
# https://pixlab.io/cmd?id=merge for more info. | |
req = requests.post('https://api.pixlab.io/merge', | |
headers={'Content-Type':'application/json'}, | |
data=json.dumps({ | |
'src':'https://pbs.twimg.com/media/CcEfpp0W4AEQVPf.jpg', | |
'key':'PIXLAB_API_KEY', # Your PixLab API Key - Get yours from https://pixlab.io/dashboard | |
'cord':[ | |
{ | |
'img': 'http://www.wowpng.com/wp-content/uploads/2016/10/lol-troll-face-png-image-october-2016-370x297.png', | |
'x': 30, | |
'y': 320 | |
}, | |
{ | |
'img': 'http://orig08.deviantart.net/67d1/f/2010/216/6/7/lol_face_by_bloodyhalfdemon.png', | |
'x': 630, | |
'y': 95 | |
}] | |
}) | |
) | |
reply = req.json() | |
if reply['status'] != 200: | |
print (reply['error']) | |
else: | |
print ("Pic Link: "+ reply['link']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment