Created
October 5, 2013 01:46
-
-
Save phamquocbuu/6835612 to your computer and use it in GitHub Desktop.
PHP Add text to image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Set the Content Type | |
header('Content-type: image/jpeg'); | |
// Create Image From Existing File | |
$jpg_image = imagecreatefromjpeg('1.jpg'); | |
// Allocate A Color For The Text | |
$white = imagecolorallocate($jpg_image, 255, 255, 255); | |
// Set Path to Font File | |
$font_path = 'font.TTF'; | |
// Set Text to Be Printed On Image | |
$text = "Trường trung học cơ sở!"; | |
// Print Text On Image | |
imagettftext($jpg_image, 55, 0, 100, 100, $white, $font_path, $text); | |
// Send Image to Browser | |
imagejpeg($jpg_image, "out.jpg"); | |
// Clear Memory | |
imagedestroy($jpg_image); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
out.jpg image is created but ,Text will not be added into new image ..