Take a look at this. I think this is what you need , you just need to modify the code. This is use for captcha images. But look at the code. It gets an image and the add text. You do have to modify it. for reading jpeg,is a different function(i think)
Very important , you need access to the font. If not you are not going to see anything.
Code: Select all
class SecImgNumber {
var $string = '';
function display()
{
$referenceid = md5(mktime()*rand());
//Select Font
$font = "secimages/century.ttf";
//Select random background image
$bgurl = 2;//rand(1, 3);
$im = ImageCreateFromPNG("secimages/bg".$bgurl.".png");
//Generate the random string
//$chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k",
//"K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v",
//"V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
$chars = array("A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","W","X","Y","Z",
"1","2","3","4","5","6","7","8","9");
$length = 4;
$textstr = "";
for ($i=0; $i<$length; $i++) {
$textstr .= $chars[rand(0, count($chars)-1)];
}
//Create random size, angle, and dark color
$size = 16;//rand(12, 16);
$angle = rand(-5, 5);
$color = ImageColorAllocate($im, rand(0, 100), rand(0, 100), rand(0, 100));
//Determine text size, and use dimensions to generate x & y coordinates
$textsize = imagettfbbox($size, $angle, $font, $textstr);
$twidth = abs($textsize[2]-$textsize[0]);
$theight = abs($textsize[5]-$textsize[3]);
$x = (imagesx($im)/2)-($twidth/2)+(rand(-20, 20));
$y = (imagesy($im))-($theight/2);
//Add text to image
ImageTTFText($im, $size, $angle, $x, $y, $color, $font, $textstr);
$this->string= $textstr;
//Output PNG Image
header("Content-Type: image/png");
ImagePNG($im);
//Destroy the image to free memory
imagedestroy($im);
}
function getString() {
return $this->string;
}
}