【发布时间】:2015-04-16 12:37:59
【问题描述】:
我正在尝试在图像上添加水印。
图片和水印图片都是从aws s3导入的。
我尝试过这样做
$watermark = tempnam(sys_get_temp_dir(), 'watermark.png');
//save the file from s3 storage to the temporary file
$content=$this->s3Manager->getFile('watermark.png',$this->verb,$watermark);
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
list($watermark_width,$watermark_height) = getimagesize($watermark);
//Get the width and height of your image - we will use this to calculate where the watermark goes
$size = getimagesize($tempFile);
//Calculate where the watermark is positioned
//In this example, it is positioned in the lower right corner, 15px away from the bottom & right edges
$dest_x = $size[0] - $watermark_width - 15;
$dest_y = $size[1] - $watermark_height - 15;
imagecopy($tempFile, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
//Finalize the image:
imagejpeg($tempFile);
return $tempFile;
imagecopy 方法失败 -
"imagecopy() 期望参数 1 为资源,字符串中给出。
我检查了图像 a 是否由 dest_y 和 dest_x 成功导入,它们看起来没问题。
【问题讨论】:
标签: php amazon-s3 watermark php-gd