I have an image on which the text is being dynamically generated via a php form. I have the location of a logo image saved to a variable from a mysql database. Is there a way to take this image and apply it to a fixed position in the image? If need be, it will have to be resized smaller to fit in this image area.
I already have a script that looks like this:
$img = imagecreatefromjpeg('coupon/coupontemplate.jpg');
$textColor = imagecolorallocate($img, 0, 0, 0); // black text
//Write first the coupon title
imagefttext($img, 16, 0, 20, 34, $textColor, 'coupon/arialbd.ttf', $title);
//Then write the coupon description
imagettftextbox($img, 13, 0, 20, 45, $textColor, 'coupon/arial.ttf', $description, 440);
//If the checkbox to include logo is checked...
if ($_POST['clogo'] == 'y') {
$logo = $row['imagecompany'];
$logo_file = "../directory/memberimages/$logo";
$logo_file_type = getimagesize($logo_file);
if ($logo_file_type['mime'] == 'image/jpg') {
$logoImage = imagecreatefromjpeg($logo_file);
} else if ($logo_file_type['mime'] == 'image/gif') {
$logoImage = imagecreatefromgif($logo_file);
} else if ($logo_file_type['mime'] == 'image/png') {
$logoImage = imagecreatefrompng($logo_file);
}
}
// Output image to the browser
//header('Content-Type: image/jpeg');
//imagejpeg($img);
// Or save to file
imagejpeg($img, 'my-text.jpg');
imagedestroy($img);
}
//}
Anyone have ideas how to do this -- get the image from the specified location and put it on the other image? Thanks!