Last active
August 29, 2015 14:07
-
-
Save xkeshav/bfd56cb12b5eab811121 to your computer and use it in GitHub Desktop.
Wish A message create colored Image
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Create Wish Card</title> | |
<link rel="stylesheet" type="text/css" href="wish.css"> | |
</head> | |
<body> | |
<form action="blank.php" method="post" > | |
<div id="wishBox"> | |
<input type="text" name="top" class="top" placeholder="Happy Diwali" > | |
<br/> | |
<textarea name="wish" class="wish" cols="25" rows="3" placeholder="Greetings" ></textarea> | |
</div> | |
<button type="submit" name="submit" value="Print">See Card</button> | |
</form> | |
<?php | |
if (extension_loaded('gd') && function_exists('gd_info')) { | |
if(!empty($_POST)) { | |
extract($_POST); | |
ob_clean(); | |
header('Content-Type: image/png'); | |
$img = LoadPNG($top,$wish); | |
imagepng($img); | |
imagedestroy($img); | |
} | |
} | |
else { | |
echo "PHP GD library is NOT installed on your web server"; | |
} | |
function LoadPNG($t,$w) | |
{ | |
/* Create a blank image */ | |
$im = @imagecreatetruecolor(700, 500) or die('Cannot Initialize new GD image stream'); | |
$c1 = mt_rand(50,250); //r(ed) | |
$c2 = mt_rand(50,250); //g(reen) | |
$c3 = mt_rand(50,250); //b(lue) | |
$bgc = imagecolorallocate($im, $c1, $c2, $c3); | |
imagefilledrectangle($im, 0, 0, 700, 500, $bgc); | |
$tc = imagecolorallocate($im, 250, 250, 250); | |
$title_font = 'JennaSue.ttf'; | |
$wish_font = 'AlexBrushRegular.ttf'; | |
$default_title = 'Happy Diwali'; | |
$default_text = 'May the glow of the diyas light ur path towards | |
progress and continued sucess happy diwali'; | |
$title = !empty($t) ? $t : $default_title; | |
$text = !empty($w) ? $w : $default_text; | |
imagettftext($im, 75, 0, 180, 175, $tc, $title_font, $title); | |
imagettftext($im, 28, 0, 30, 400, $tc, $wish_font, $text); | |
return $im; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment