Created
March 31, 2021 01:26
-
-
Save symisc/c91a6d02880b86925aa6854669d8f03d 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
<?php | |
/* | |
* PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github | |
* https://github.com/symisc/pixlab-php | |
*/ | |
require_once "pixlab.php"; | |
/* | |
* 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. | |
*/ | |
$key = 'PIXLAB_API_KEY'; # Your PixLab API Key - Get yours from https://pixlab.io/dashboard | |
$pix = new Pixlab($key); | |
if( !$pix->post('merge',array( | |
'src' => 'https://pbs.twimg.com/media/CcEfpp0W4AEQVPf.jpg', | |
'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 | |
]] | |
))){ | |
echo $pix->get_error_message(); | |
die; | |
} | |
echo "Pic Link: ".$pix->json->link."\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment