Skip to content

Instantly share code, notes, and snippets.

@Shaz3e
Created February 16, 2014 13:57
Show Gist options
  • Save Shaz3e/9034549 to your computer and use it in GitHub Desktop.
Save Shaz3e/9034549 to your computer and use it in GitHub Desktop.
Add text to images with PHP
<?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