I have a function that takes for images and combines them into a single wide image. That seems to work. Now I am trying to put some text on the images and that is not.
The five lines after: // Allocate A Color For The Text, are the ones i added to create the text. Is there something I'm missing? I don't see any errors when I run the code.
function merge($filename_w, $filename_x, $filename_y, $filename_z,$filename_result, $text) {
// Get dimensions for specified images
list($width_w, $height_w) = getimagesize($filename_w);
list($width_x, $height_x) = getimagesize($filename_x);
list($width_y, $height_y) = getimagesize($filename_y);
list($width_z, $height_z) = getimagesize($filename_z);
// Create new image with desired dimensions
$image = imagecreatetruecolor($width_w + $width_x + $width_y + $width_z, $height_x);
// Load images and then copy to destination image
$image_w = imagecreatefromjpeg($filename_w);
$image_x = imagecreatefromjpeg($filename_x);
$image_y = imagecreatefromjpeg($filename_y);
$image_z = imagecreatefromjpeg($filename_z);
imagecopy($image, $image_w, 0, 0, 0, 0, $width_w, $height_w);
imagecopy($image, $image_x, $width_w, 0, 0, 0, $width_x, $height_x);
imagecopy($image, $image_y, $width_w + $width_x, 0, 0, 0, $width_y, $height_y);
imagecopy($image, $image_z, $width_w + $width_x + $width_y, 0, 0, 0, $width_z, $height_z);
// Allocate A Color For The Text
$white = imagecolorallocate($image, 255, 255, 255);
// Set Path to Font File
$font_path = './tahoma.ttf';
// Print Text On Image
imagettftext($image, 25, 0, 75, 300, $white, $font_path, "Test text");
// Save the resulting image to disk (as JPEG)
imagejpeg($image, $filename_result);
// Clean up
imagedestroy($image);
imagedestroy($image_w);
imagedestroy($image_x);
imagedestroy($image_y);
imagedestroy($image_z);
}