I am having a problem in getting a watermark on an image that is called from a database. I can static image static image to work fine, but when I try to use it on a dynamically called image, I get these errors. I am trying to merge two images into one, not text on an image.

Warning: imagecreatefromjpeg($image_file) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/content/a/l/i/alinde52/html/imagesDetail.php on line 257

Warning: imagesy(): supplied argument is not a valid Image resource in /home/content/a/l/i/alinde52/html/imagesDetail.php on line 263

Warning: imagecopymerge(): supplied argument is not a valid Image resource in /home/content/a/l/i/alinde52/html/imagesDetail.php on line 263

Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/content/a/l/i/alinde52/html/imagesDetail.php on line 265

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/content/a/l/i/alinde52/html/imagesDetail.php on line 266

I beleive all the errors are from the same issue.

Here is the code I am using:

$id = $row_WADAimages;
$query_wat = "SELECT image_file FROM images WHERE image_id = '$id' ";
$result_wat = mysql_query($query_wat) or die();
$row = mysql_fetch_array($result_wat);
$file_name = $row_WADAimages;

$fileName = $file_name;
$maxHeight = '450px';
$maxWidth = '300px';
$imageDir = "images/";


//now add the watermark to the image.
$watermark = imagecreatefrompng('images/watermark.png');
$image = imagecreatefromjpeg('$image_file'); //This seems to be my issue
//get the dimensions of the watermark
list($width_orig, $height_orig) = getimagesize('images/watermark.png');

// Water mark process
imagecopymerge($image, $watermark, 0, imagesy($image)-$height_orig, 0, 0, $width_orig, $height_orig, 100);

imagejpeg($image, $imageDir.$fileName, 90);
imagedestroy($image);

return $imageURL.$fileName;


?>

I have also wrapped the code in a function, eliminating the error results, and I get the image, but not both.

Can anyone set me in the right direction.

Gary

Recommended Answers

All 2 Replies

Replace $image_file with $file_name

Thank you for your reply, but that is not it.

Gary

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.