I have an image in which text is dynamically generated through a php form. I have the location of the logo image saved in a variable from mysql database. Is there any way to make this image and apply it to a fixed position on the image? If necessary, it should be resized smaller to fit this area of โโthe image.
I already have a script that looks like this:
$img = imagecreatefromjpeg('coupon/coupontemplate.jpg');
$textColor = imagecolorallocate($img, 0, 0, 0);
imagefttext($img, 16, 0, 20, 34, $textColor, 'coupon/arialbd.ttf', $title);
imagettftextbox($img, 13, 0, 20, 45, $textColor, 'coupon/arial.ttf', $description, 440);
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);
}
}
imagejpeg($img, 'my-text.jpg');
imagedestroy($img);
}
Does anyone have any idea how to do this - get the image from the specified location and put it on another image? Thank!
source
share