Created
December 16, 2016 09:29
-
-
Save ZahidRasheed/c68e26a979707ebbd5f77c8008c68da4 to your computer and use it in GitHub Desktop.
This file contains 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 | |
//Set Variables: | |
$background = "bg.jpg"; //Background chose by user | |
$logo = "logo.png"; //This logo will always remain same | |
$userLogo = "20.png"; //Logo created by user. | |
$savePath = "/output/"; //Where to Save? | |
$showNotSave = true; | |
//No need to change anything below.... | |
$bgImage = imagecreatefromjpeg($background); | |
//Apply Logo | |
$img = imagecreatefrompng($logo); | |
list($logoWidth, $logoHeight) = getimagesize($logo); | |
imagecopy($bgImage, $img, 30, 0, 0, 0, $logoWidth, $logoHeight); | |
imagedestroy($img); | |
//Apply Custom Logo | |
$img = imagecreatefrompng($userLogo); | |
$wx = imagesx($bgImage) / 2 - imagesx($img) / 2; | |
$wy = imagesy($bgImage) / 2 - imagesy($img) / 2; | |
imagecopy($bgImage, $img, $wx, $wy, 0, 0, imagesx($img), imagesy($img)); | |
imagedestroy($img); | |
if ($showNotSave) { | |
header('Content-Type: image/png'); | |
imagepng($bgImage); | |
} else { | |
imagepng($bgImage, $savePath); | |
} | |
imagedestroy($bgImage); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment