首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >图像水印无效

图像水印无效
EN

Stack Overflow用户
提问于 2013-10-30 10:54:23
回答 2查看 382关注 0票数 0

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

警告:imagecreatefromjpeg(上载/##..jpg):未能打开流:在

我使用来自php.net的代码进行了一些更改:

代码语言:javascript
复制
  // 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);
?>
EN

回答 2

Stack Overflow用户

发布于 2013-10-30 10:59:41

您可以使用我创建的textPainter类在图像上打印文本:https://github.com/alvarotrigo/PHP-Backend/tree/master/textPainter

活演示

票数 0
EN

Stack Overflow用户

发布于 2013-10-30 11:02:06

我觉得你走错了影像$im = imagecreatefromjpeg($image);的路。检查$image的值,为了测试目的,将两个映像复制到同一个目录中,然后运行脚本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19680286

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档