【发布时间】:2013-10-30 10:54:23
【问题描述】:
我正在尝试为上传的图片添加水印。 不幸的是,我收到了这个错误:'
警告:imagecreatefromjpeg(upload/##.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);
?>
【问题讨论】:
-
检查您的 logo.png 位置,它存储的位置。它应该在文件所在的同一目录中。