我有一個圖像,文本是通過php的形式動態生成的。我有一個徽標圖像的位置保存到一個MySQL數據庫的變量。有沒有辦法拍攝這張照片並將其應用到圖像中的固定位置?如果需要,它將不得不縮小以適合此圖像區域。在PHP的另一幅圖像中放置圖像
我已經有一個腳本,看起來像這樣:
$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);
}
//}
任何人都有想法如何做到這一點 - 從指定位置獲取圖像,並把它的其他形象?謝謝!
意味着你想把徽標放在每個生成的圖像?圖像上的圖像。對?? – diEcho 2011-05-26 08:26:25
@diEcho - yep! :) – Sara 2011-05-26 08:48:21
順便說一句,這樣做的圖像的一般名稱是「水印」 - 這可能會幫助你[找到更多的資源](http://www.google.co.uk/search?sourceid=chrome&ie=UTF- 8 q = PHP +圖像+水印)。 – 2011-05-26 08:53:43