Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.