how to merge images and text?
Moderator: General Moderators
how to merge images and text?
Hello,
Guys I need to merge 2 images; one from file and the other one from db.
then after merging, I need to input text inside the merged image.
any help or tutorial for this problem??
Thanks and God bless
Guys I need to merge 2 images; one from file and the other one from db.
then after merging, I need to input text inside the merged image.
any help or tutorial for this problem??
Thanks and God bless
Re: how to merge images and text?
thanks jshpro2 for the quick reply.
anyway here is my code used for this problem.
I'm having problem with imagecreatefromjpeg($dbpic);
but if you change imagecreatefromjpeg($dbpic) with imagecreatefromjpeg(picture.jpg);
its working fine. how can I used db image with imagecreatefromjpeg()
any idea?
Thanks
anyway here is my code used for this problem.
Code: Select all
header('Content-type: image/jpeg');
$dbpic = "pictureFromDB.php";
$watermark = imagecreatefromjpeg($dbpic);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg('ToMergetemplate.jpg');
$size = getimagesize('ToMergetemplate.jpg');
$dest_x = 70;
$dest_y = 350;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0,0, $watermark_width, $watermark_height, 100);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
but if you change imagecreatefromjpeg($dbpic) with imagecreatefromjpeg(picture.jpg);
its working fine. how can I used db image with imagecreatefromjpeg()
any idea?
Thanks
Re: how to merge images and text?
I'm having problem with imagecreatefromjpeg($dbpic);
Code: Select all
echo( 'value is correct: ' . (bool)($dbpic=='picture.jpg'));
var_dump( $dbpic );
Re: how to merge images and text?
ah.. I get your point.
$dbpic = "pictureFromDB.php";
how can i tell imagecreatefromjpeg() that $dbpic output a jpeg file?
pictureFromDB.php code
$dbpic = "pictureFromDB.php";
how can i tell imagecreatefromjpeg() that $dbpic output a jpeg file?
pictureFromDB.php code
Code: Select all
include('config/connect.inc.php');
$conn = mysql_connect($host,$user,$pass);
$dbCon = mysql_select_db($db);
$query = "SELECT tcpd_photo FROM tbl_client_per_details where tcpd_id=51";
$exec = mysql_query($query);
$rs = mysql_fetch_array($exec, MYSQL_NUM);
// get the image from the db
$sql = "SELECT image FROM tbl_client_image WHERE image_id=54";
// the result of the query
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
// set the header for the image
header("Content-type: image/jpeg");
echo mysql_result($result, 0);
// close the db link
mysql_close($link);
Re: how to merge images and text?
the variable is being populated by the database, so I would change the data in the database, perhaps you're selecting the wrong row or something?
Re: how to merge images and text?
pictureFromDB.php is correct. this php file output a jpeg file.jshpro2 wrote:the variable is being populated by the database, so I would change the data in the database, perhaps you're selecting the wrong row or something?
but when I use it in imagecreatefromjpeg()
by :
imagecreatefromjpeg("pictureFromDB.php"); or
$dbpic = "pictureFromDB.php";
imagecreatefromjpeg($dbpic);
I'm having a problem. How can I tell imagecreatefromjpeg($dbpic) or pictureFromDB.php is a jpeg file
Re: how to merge images and text?
got it!
I used imagecreatefromjpeg("http://localhost/OFCARD/pictureFromDB.php");
I used URL this tell imagecreatefromjpeg that pictureFromDB..php is a jpeg file.
Thanks jshpro2 because of you I'm able to notice my error.
God bless
I used imagecreatefromjpeg("http://localhost/OFCARD/pictureFromDB.php");
I used URL this tell imagecreatefromjpeg that pictureFromDB..php is a jpeg file.
Thanks jshpro2 because of you I'm able to notice my error.
God bless
Re: how to merge images and text?
Do you realize youre making a 2nd web request in the background by using URL wrappers ( "http:// in a filename" )?
A better way would be to take the code in that file and push it back to a function
A better way would be to take the code in that file and push it back to a function