1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <?php
//Set the Content Type
header('Content-type: image/jpeg');
// Create Image From Existing File
$jpg_image = imagecreatefromjpeg('img/sunset.jpg');
// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 255, 255, 255);
// Set Path to Font File
$font_path = 'fonts/verdana.ttf';
// Set Text to Be Printed On Image
$text = "This is a sunset!";
// Print Text On Image
imagettftext($jpg_image, 25, 0, 75, 300, $white, $font_path, $text);
$nameToStore = time() . '_pic.jpg';
// Send Image to Browser
imagejpeg($jpg_image,'img/' . $nameToStore);
// Clear Memory
imagedestroy($jpg_image); |
Partager