I tried this imagejpeg() php method, but it returns an image to a browser on running the code.
However I need a method that returns an image URL so that i can use it in my img tag.
Currently i have to use -
<img src="siteurl/myphpfile.php" />
but i think its better if the method returns an image handler so that i can use it in my img tag, like -
<img src="image.jpg" />
My myphpfile.php is the file that contains the code.
Searched many functions at php manuals but no luck, I am also using this method imagettftext()
for text addition over image.
Total code in the File --
<?php
function myimagecreate( $myname ) {
$headurl = 'template_header01.jpg';
header('Content-type: image/jpeg');
$text = "My Full Text";
$name = $text.".jpg";
$jpg_image = imagecreatefromjpeg($headurl);
$black = imagecolorallocate($jpg_image, 1, 1, 1);
$font_path = 'myfont/arial.ttf';
imagettftext($jpg_image, 24, 0, 175, 85, $black, $font_path, $text);
imagejpeg($jpg_image,'mynameimg.jpg');
imagedestroy($jpg_image);
return 'mynameimg.jpg';
}
$to = 'swapnesh20032003@gmail.com';
$subject = $myname;
$message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kings</title>
</head>
<body>
<table width="100%"><tr><td valign="bottom" align="center" height="282"><img src="'.myimagecreate( $myname ).'" /></td></tr></table></table></body></html>';
mail($to,$subject,$message);
?>