Struggling with this one I need to watermark these images. Each image sits in one directory. the URLS to the images come from the database depending on which link they click.
Not a problem so far. Well I want to water mark the images that the database provides the address to. There is 5. but this should be flexible, to format 1 image or however many I specify by calling the function like:
[code=php]
$img1 = imagemarker($img1);
//or multiples
$img1 = imagemarker($img1);
$img1 = imagemarker($img2);
$img1 = imagemarker($img3);
This is my exsisting query to handle grabbling info
Query the table for infomation out of the DB (images, story, name, date)
[code=php]
$table_name2 = “bob_storys”;
$sql2 =”SELECT * FROM $table_name2 WHERE band = ‘$topic'”;
$result2 = mysql_query($sql2, $connection) or die (mysql_error());
$num2 = mysql_num_rows($result2);
while ($row2 = mysql_fetch_array($result2))
{
$id = ($row2[‘id’]);
$band = ($row2[‘band’]);
$story = ($row2[‘story’]);
$date = ($row2[‘date’]);
$img1 = ($row2[‘img1’]);//image 1 url (all these relative to the directory)
$img2 = ($row2[‘img2’]);//image 2 url
$img3 = ($row2[‘img3’]);//image 3 url
$img4 = ($row2[‘img4’]);//image 4 url
$center = ($row2[‘center’]);//center image 5 url
// Formatting down here
}
found this script searching google,
I have made changes to it to make it a function but I am not sure how to get it to handle each image (5 of them) and return them so it is just a function I can use universaly for any image on any page.
[code=php]
function imagemarker()// how do I get it in here? $input?
{
header(‘content-type: image/jpeg’); //define content type
$watermark = imagecreatefrompng(‘watermark.png’); //where and how big
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg($_GET[‘src’]); //from where
$size = getimagesize($_GET[‘src’]); //get sizes
$dest_x = $size[0] – $watermark_width – 5; // get image size and set 5px margin
$dest_y = $size[1] – $watermark_height – 5;
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0,
$watermark_width, $watermark_height, 100); //merge!
imagejpeg($image);
imagedestroy($image); // Destroy image from the GD library
imagedestroy($watermark);
}
what should it return so I can access each one with the assigned variables from the while in the first php snippet above?
thanks for your help all these image altering variables are new to me.