| Current Path : /var/www/html/mmishra/mm/ |
| Current File : /var/www/html/mmishra/mm/text2image.php |
<?php
// Set the content-type
header('Content-type: image/jpeg');
$title = $_REQUEST["title"];
//$img = "www.uprtou.ac.in/gallery/bird1.jpg";//$_REQUEST["img"];
$img = $_REQUEST["image"];
// Create the image
$fonts = array('HTOWERT.TTF','MTCORSVA.TTF','BAUHS93.TTF','georgia.TTF');
$no = rand(0,3);
$font = $fonts[$no];
$i = imageloadfont($font);
$im = imagecreatefromjpeg($img);
/* See if it failed */
if(!$im) {
/* Create a black image */
$im = imagecreatetruecolor(450, 30);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 450, 30, $bgc);
/* Output an error message */
imagestring($im, 1, 5, 5, 'Error loading ' . $img, $tc);
} else {
$tc = imagecolorallocate($im, 0, 0, 0);
// Add the text
imagettftext($im, 24, 10, 50, 130, $tc, $font, $title);
// Using imagepng() results in clearer text compared with imagejpeg()
//imagepng($im);
imagejpeg($im);
}
imagedestroy($im);
?>