Veronica's Text on an Image
Image courtesy of Jason Leung on unsplash
SLAVE CODE FOLLOWS
<?php // combine text with image
$name = "H o o r a y !";
// get the images from files
$image = imagecreatefromjpeg("../images/jason-leung-Xaanw0s0pMk-unsplash_sm.jpg");
// get sizes
$width = imagesx($image);
$height = imagesy($image);
$font = "fonts/arial.ttf";
// sets the current foreground color
$color = imagecolorallocate($image, 170, 255, 0);
// combines the image with text using the following specs
// (image, font-size, angle-rotation, x-coord, y-coord, text-color, font-name, text)
imagettftext($image, 20, 18, 20, $height - 8, $color, $font, $name);
//=== display the image
// tell the server that a PNG image follows
header("Content-type: image/png");
// display the image
imagepng($image);
// destroy the image (i.e., release memory)
imagedestroy ($image);
?>