Created
October 4, 2014 06:00
-
-
Save lukespragg/f41c91236abf3f978cd9 to your computer and use it in GitHub Desktop.
Unfinished meme generator that was actually meant for something else, but is just scrap now...
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 | |
// Set the content-type | |
header ("Content-type: image/jpeg"); | |
// Get text from URL | |
$text = $_GET['text']; | |
// Create some colors | |
$white = imagecolorallocate($im, 255, 255, 255); | |
$grey = imagecolorallocate($im, 128, 128, 128); | |
$black = imagecolorallocate($im, 0, 0, 0); | |
// Select the text font | |
$font = 'Oswald-Bold.ttf'; | |
// Get font dimensions | |
$width = imagefontwidth($font) * strlen($string) ; | |
$height = imagefontheight($font) ; | |
// Grab original image | |
$im = imagecreatefromjpeg('grumpycat.jpg'); | |
// Set new image dimensions | |
$x = imagesx($im) - $width; | |
$y = imagesy($im) - $height; | |
// Add text to new image | |
//imagefttext($im, 22, 0, $x, $y, $black, $font, $text); | |
//imagefttext($im, 20, 0, $x, $y, $white, $font, $text); | |
imagettftext($im, 20, 0, $x, $y, $black, $font, $text); | |
// Create new image | |
imagejpeg($im); | |
imagedestroy($im); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment