Skip to content

Instantly share code, notes, and snippets.

@potch
Created October 31, 2014 00:25
Show Gist options
  • Select an option

  • Save potch/27d9491be03d51b388e8 to your computer and use it in GitHub Desktop.

Select an option

Save potch/27d9491be03d51b388e8 to your computer and use it in GitHub Desktop.
Emo Name Generator
<?php
header("Content-type: image/png");
$bgs = array("bg1.png", "bg2.png", "bg3.png", "bg4.png");
$im = imagecreatetruecolor(512, 132);
$im2 = imagecreatefrompng($bgs[array_rand($bgs)]);
$wm = imagecolorallocatealpha($im, 255, 255, 255, 64);
$black = imagecolorallocatealpha($im, 0, 0, 0, 32);
$background = imagecolorallocate($im, 0, 0, 0);
$ctext = imagecolorallocate($im, 255, 72, 16);
$sTextfile = "./1.txt";
if ($words = file($sTextfile)) {
$bname = rtrim($words[array_rand($words)]) . ' ';
}
$sTextfile2 = "./2.txt";
if ($words = file($sTextfile2)) {
$bname .= rtrim($words[array_rand($words)]) . ' ';
}
$sTextfile3 = "./3.txt";
if ($words = file($sTextfile3)) {
$bname .= rtrim($words[array_rand($words)]);
}
$box = imagettfbbox( 72, 0, 'DEARJ.TTF', $bname);
$width = $box[2] - $box[0];
$height = $box[2] - $box[0];
imagefill($im, 1, 1, $background);
imagecopy ($im, $im2, 0, 0, 0, 0, 512, 128);
imagerectangle($im, 0,0,511,159,$background);
imagettftext ( $im, 72, 0, 256-$width / 2+1,73 , $black, 'DEARJ.TTF', $bname);
imagettftext ( $im, 72, 0, 256-$width / 2,72 , $ctext, 'DEARJ.TTF', $bname);
imagestringup ($im, 2, 498, 100, '(c)ipamusic.com', $wm);
imagepng($im);
imagedestroy($im);
imagedestroy($im2);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment