Skip to content

Instantly share code, notes, and snippets.

Created September 28, 2011 14:03
Show Gist options
  • Save anonymous/1248010 to your computer and use it in GitHub Desktop.
Save anonymous/1248010 to your computer and use it in GitHub Desktop.
hipsterstuff
<?php
header("Content-type: image/png");
//1line per column
$text=array(0=>"THIS ISN'T",1=>"ORGANIC",2=>"AND I'M NOT",3=>"A FCKN",4=>"HIPSTER");
$largeur=350;
$line_height=50;
$hauteur=sizeof($text)*$line_height;
// Create the image
$im = imagecreatetruecolor($largeur, $hauteur);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 0, 0, 0);
$blue = imagecolorallocate($im, 0, 62, 126);
imagefilledrectangle($im, 0, 0, $largeur, $hauteur, $white);
// Replace path by your own font path
$font = 'ArialBold.ttf';
for($i=0;$i<=sizeof($text);$i++) {
//Center the text
$size = imagettfbbox(40, 0, $font, $text[$i]);
$long_text = $size[2]-$size[0];
$posx=($largeur-$long_text);
// Add the text
imagettftext($im, 40, 0, $posx, $line_height+$line_height*$i, $grey, $font, $text[$i]);
}
imagepng($im);
imagedestroy($im);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment