14.09.2014, 13:25
Make sure your image work without the mysql information.
By the way, i also had problems with imagecreatefrompng , so i created a true color one instead, and placed the image above it with imagecopy.
Here is a simple working PHP image:
Hope i helped you.
By the way, i also had problems with imagecreatefrompng , so i created a true color one instead, and placed the image above it with imagecopy.
Here is a simple working PHP image:
PHP код:
// Establish image factors:
$font_size = 18; // Font size is in pixels.
$font_file = 'Tahoma.ttf'; // This is the path to your font file.
// Create image:
$image = imagecreatetruecolor(450, 110); // Create a truecolor image 450x110
// Allocate text and background colors (RGB format):
$bg_color = imagecolorallocate($image, 0, 0, 0);
$text_color = imagecolorallocate($image,237,176,07);
// Fill image:
imagefill($image, 0, 0, $bg_color);
// Bg IMG
$bg_image = imagecreatefrompng("bg.png"); // Load PNG image
imagecopy($image,$bg_image,0,0,0,0,450,110); // Then copy it into our image
// Add TrueType text to image:
imagettftext($image, $font_size, 0, 100, 60, $text_color, $font_file, "This is a test!");
// Generate and send image to browser:
header('Content-type: image/png');
imagepng($image);
// Destroy image in memory to free-up resources:
imagedestroy($image);