I am a bit of a PHP dabbler/beginner, and I am trying to write a script to watermark uploaded images. The watermark is variable, based on information supplied by the logged-in user.
What I need now should be relatively easy, assuming displayed images (or their paths) are stored in a variable that I can call. Or is there an easier way?
<?php
global $user;
$name = $user->name;
$uid = $user->uid;
$filename = $name;
// first name query and variable
$fquery = "SELECT value FROM profile_values WHERE uid='$user->uid' AND fid='3'";
$result = mysql_query($fquery);
while ($row = mysql_fetch_object($result)) {
$fname = "$row->value";
}
// last name query and variable
$lquery = "SELECT value FROM profile_values WHERE uid='$user->uid' AND fid='4'";
$result = mysql_query($lquery);
while ($row = mysql_fetch_object($result)) {
$lname = "$row->value";
}
// concatenate the full name
$fullname = $fname . " " . $lname;
// create an image with width 'x', height 'y'
$image = imagecreate(200, 20);
// create a background color and then set it to transparent
$background = imagecolorallocate($image, 255, 255, 255);
ImageColorTransparent($image, $background);
ImageInterlace($image, false);
// set black color for the text
$black = imagecolorallocate($image, 0, 0, 0);
// write the variable string to the image
// the top left of the text is at the position (10, 2)