Php 图像水印不';行不通

Php 图像水印不';行不通,php,image,watermark,Php,Image,Watermark,我正在尝试向上传的图像添加水印。 不幸的是,我得到了这个错误:' 警告:imagecreatefromjpeg(上载/###.jpg):无法打开流:否 中的此类文件或目录 我正在使用php.net中的代码,但做了一些更改: // Load the stamp and the photo to apply the watermark to $stamp = imagecreatefrompng('logo.png'); $im = imagecreatefromjpeg($image); /

我正在尝试向上传的图像添加水印。 不幸的是,我得到了这个错误:'

警告:imagecreatefromjpeg(上载/###.jpg):无法打开流:否 中的此类文件或目录

我正在使用php.net中的代码,但做了一些更改:

  // Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefrompng('logo.png');
$im = imagecreatefromjpeg($image);

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

您可以使用创建的
textpainer
类在图像上打印文本:


我觉得您传递的图像路径错误
$im=imagecreatefromjpeg($image)。检查$image的值,出于测试目的,将两个图像复制到同一目录中并运行脚本。

检查logo.png的存储位置。它应该位于文件所在的同一目录中。