Imagecopymerge() returns TRUE, but with invalid image resource

I have the following code:

$final_image = imagecopymerge($base_image, $watermark_image, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); 

It gives me no errors (and it actually returns TRUE), but when I try to use $final_image in any other function (such as imagedestroy() which only takes 1 parameter) I get the error that the supplied argument is not a valid Image resource.

GD is installed. Also all the parameters in the code above ($base_image, $watermark_image, $dest_x, etc) are valid and working.

What am I missing here!? How can the function return TRUE but not actually create a valid image resource?

What do you get when you var_dump($final_image); ?


Are you saving the image after performing imagecopymerge()?

imagecopymerge($base_image, $watermark_image, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);


Ah! It seems I had a fundamental misunderstanding of how the function worked. I was passing $final_image along as the image resource in the functions that followed.

Makes sense in retrospect. Thanks tgavin!