Created
October 25, 2018 14:55
-
-
Save Pierstoval/d4acaed8e3caa4814b873644276aaaa3 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 | |
$h = fopen('php://memory', 'ab+'); | |
$gd = @imagecreate(110, 20); | |
if (false === $gd) { | |
throw new \RuntimeException('GD image is invalid'); | |
} | |
$background_color = imagecolorallocate($gd, 0, 0, 0); | |
$text_color = imagecolorallocate($gd, 233, 14, 91); | |
imagestring($gd, 1, 5, 5, 'A Simple Text String', $text_color); | |
imagepng($gd, $h); | |
rewind($h); | |
header('Content-Type: image/png'); | |
$stdout = fopen('php://output', 'rb'); | |
stream_copy_to_stream($h, $stdout); | |
fclose($stdout); | |
fclose($h); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment