Hello everyone! I was trying to follow along with this tutorial:

http://www.sitepoint.com/article/watermark-images-php/

and everything worked fine until the end. Basically I'm trying to write a script that both resizes and watermarks images for a couple of websites I'm working on, so that I don't have to go through and do it for every picture manually. My resize script worked no problem, but when I tried to add the watermarking part (from the above tutorial) it stopped displaying the images and instead puts the url for the script on the page???? When I remove the image/jpeg header it outputs the resized image just fine, but the watermarked one is a bunch of symbols.

I have attached my script, I'm very new to PHP so please try not to laugh too hard if I have made a very silly mistake. :)

Perhaps I should try posting my code in the actual thread :) Here is the bit that's giving me trouble:

$wm = imagecreatefrompng('kil_wm.png');

$wm_width = imagesx($wm);
$wm_height = imagesy($wm);

$image = imagecreatefromjpeg('test.jpg');

$size = getimagesize('test.jpg');

$dest_x = $size[0] - $wm_width - 5;
$dest_y = $size[1] - $wm_height - 5;

imagecopymerge($image, $wm, $dest_x, $dest_y, 0, 0, $wm_width, $wm_height, 100);

imagejpeg($image);  
imagedestroy($image);  
imagedestroy($wm);

So, what am I doing wrong? Thanks!

Okay so somebody else tried the above code and it worked for them, leading me to believe that there must be something wrong with my GD2 configuration. Any ideas what that might be?

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.