上传图片并制作水印

时间:2014-07-14 09:04:15

标签: php watermark

private function upload($name, $types){
        for($i = 0; $i < count($name); $i++){
            move_uploaded_file($types[$i], $this->_direction . $name[$i]);
            $this->waterMark($name[$i]);
        }
    }

此功能上传照片并且有效。 但这个水印功能不起作用:(

private function waterMark($imgs){
        $stamp = imagecreatefrompng('http://localhost/public_html/img/watermark.png');
        $im = imagecreatefromjpeg('http://localhost/public_html/uploaded/' . $imgs);

        $marge_right = 10;
        $marge_bottom = 10;
        $sx = imagesx($stamp);
        $sy = imagesy($stamp);

        imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));

        header('Content-type: image/png');
        imagepng($im);
        imagedestroy($im);
    }

我有什么错误?

0 个答案:

没有答案