/    Sign up×
Community /Pin to ProfileBookmark

watermarking images out of the database. Numerous images one page.

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);
[/code]

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
}
[/code]

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);

}

[/code]

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.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bokehMar 11.2006 — I'm confused. Do you want to store the watermarked images on the server for later use or do the want to watermark the images as they are being sent but not save a copy on the server (increases server load). You script does the latter.
Copy linkTweet thisAlerts:
@Markbad311authorMar 11.2006 — Didn't realize I could run a script and format these. hmm... well I don't want to increase the load of the server. Maybe I would do this temporarily while I work on the other. I have already seen my images on another site yesterday. (following referer links). crappy
×

Success!

Help @Markbad311 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...