Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php在s3导入的图像上添加水印_Php_Amazon S3_Watermark_Php Gd - Fatal编程技术网

php在s3导入的图像上添加水印

php在s3导入的图像上添加水印,php,amazon-s3,watermark,php-gd,Php,Amazon S3,Watermark,Php Gd,我正在尝试在图像上添加水印 图像和水印图像都是从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,$

我正在尝试在图像上添加水印

图像和水印图像都是从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是资源,字符串在中给出


我检查了dest_y和dest_x是否成功导入了图像,它们似乎没有问题。

正如错误所述,imagecopy需要一个资源。我假设tempfile是一个字符串。您可以这样做

$res = imagecreatefrompng($tempfile)
然后把这个传给imagecopy