我试图在上传的图像中添加水印。不幸的是,我得到了这个错误:‘
警告: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);
?>发布于 2013-10-30 10:59:41
您可以使用我创建的textPainter类在图像上打印文本:https://github.com/alvarotrigo/PHP-Backend/tree/master/textPainter
活演示
发布于 2013-10-30 11:02:06
我觉得你走错了影像$im = imagecreatefromjpeg($image);的路。检查$image的值,为了测试目的,将两个映像复制到同一个目录中,然后运行脚本。
https://stackoverflow.com/questions/19680286
复制相似问题