Created
February 16, 2014 13:57
-
-
Save Shaz3e/9034549 to your computer and use it in GitHub Desktop.
Add text to images with PHP
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
<?php | |
header ("Content-type: image/jpeg"); | |
$string = "All Copyrights reserved."; | |
$font = 4; | |
$width = imagefontwidth($font) * strlen($string) ; | |
$height = imagefontheight($font) ; | |
// your file name | |
$im = imagecreatefromjpeg("shaz3e.jpg"); | |
$x = imagesx($im) - $width ; | |
$y = imagesy($im) - $height; | |
$backgroundColor = imagecolorallocate ($im, 255, 255, 255); | |
$textColor = imagecolorallocate ($im, 0, 0,0); | |
imagestring ($im, $font, $x, $y, $string, $textColor); | |
imagejpeg($im); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment