Home >Backend Development >PHP Tutorial >Explain to you the specific method of adding watermark to images in PHP_PHP Tutorial

Explain to you the specific method of adding watermark to images in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-15 13:29:09946browse

When we are building a website, we will all encounter the need to add watermarks to the pictures uploaded on the website. It will definitely be very troublesome and impractical to add watermarks one by one manually. So, today we will accept the specific method of adding watermark to pictures in PHP and simplify the steps.

  • The specific code to add watermark to the picture is as follows:

    <ol class="dp-xml">
    <li class="alt">
    <span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN>   </SPAN></SPAN><LI class=""><SPAN>/******************************************************************************   </SPAN><LI class=alt><SPAN> </SPAN><LI class=""><SPAN>参数说明:   </SPAN><LI class=alt><SPAN>$max_file_size  : 上传文件大小限制, 单位BYTE   </SPAN><LI class=""><SPAN>$destination_folder : 上传文件路径   </SPAN><LI class=alt><SPAN>$watermark   : 是否附加水印(1为加水印,其他为不加水印);   </SPAN><LI class=""><SPAN> </SPAN><LI class=alt><SPAN>使用说明:   </SPAN><LI class=""><SPAN>1. 将PHP.INI文件里面的"</SPAN><SPAN class=attribute><FONT color=#ff0000>extension</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>php_gd2</FONT></SPAN><SPAN>.dll"一行前面的;号去掉,因为我们要用到GD库;   </SPAN></SPAN><LI class=alt><SPAN>2. 将</SPAN><SPAN class=attribute><FONT color=#ff0000>extension_dir</FONT></SPAN><SPAN> =改为你的php_gd2.dll所在目录;   </SPAN></SPAN><LI class=""><SPAN>******************************************************************************/   </SPAN><LI class=alt><SPAN> </SPAN><LI class=""><SPAN>//上传文件类型列表   </SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>uptypes</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>array</FONT></SPAN><SPAN>(   </SPAN></SPAN><LI class=""><SPAN>    'image/jpg',   </SPAN><LI class=alt><SPAN>    'image/jpeg',   </SPAN><LI class=""><SPAN>    'image/png',   </SPAN><LI class=alt><SPAN>    'image/pjpeg',   </SPAN><LI class=""><SPAN>    'image/gif',   </SPAN><LI class=alt><SPAN>    'image/bmp',   </SPAN><LI class=""><SPAN>    'image/x-png'   </SPAN><LI class=alt><SPAN>);   </SPAN><LI class=""><SPAN> </SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>max_file_size</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>2000000</FONT></SPAN><SPAN>;     //上传文件大小限制, 单位BYTE   </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>destination_folder</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"uploadimg/"</FONT></SPAN><SPAN>; //上传文件路径   </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>watermark</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>1</FONT></SPAN><SPAN>;      //是否附加水印(1为加水印,其他为不加水印);   </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>watertype</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>1</FONT></SPAN><SPAN>;      //水印类型(1为文字,2为图片)   </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>waterposition</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>1</FONT></SPAN><SPAN>;     //水印位置(1为左下角,2为右下角,3为左上角,4为右上角,5为居中);   </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>waterstring</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"http://www.xplore.cn/"</FONT></SPAN><SPAN>;  //水印字符串   </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>waterimg</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"xplore.gif"</FONT></SPAN><SPAN>;    //水印图片   </SPAN></SPAN><LI class=""><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>imgpreview</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>1</FONT></SPAN><SPAN>;      //是否生成预览图(1为生成,其他为不生成);   </SPAN></SPAN><LI class=alt><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>imgpreviewsize</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>1</FONT></SPAN><SPAN>/2;    //缩略图比例   </SPAN></SPAN><LI class=""><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span>   </span>
    </li>
    <li class="alt">
    <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>html</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
    </li>
    <li class="">
    <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>head</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
    </li>
    <li class="alt">
    <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>title</SPAN><SPAN class=tag>></span></font></strong><span>ZwelL图片上传程序</span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>title</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
    </li>
    <li class="">
    <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>style</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>type</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"text/css"</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span>   </span>
    </li>
    <li class="alt">
    <span><!--   </SPAN><LI class=""><SPAN>body   </SPAN><LI class=alt><SPAN>{   </SPAN><LI class=""><SPAN>     font-size: 9pt;   </SPAN><LI class=alt><SPAN>}   </SPAN><LI class=""><SPAN>input   </SPAN><LI class=alt><SPAN>{   </SPAN><LI class=""><SPAN>     background-color: #66CCFF;   </SPAN><LI class=alt><SPAN>     border: 1px inset #CCCCCC;   </SPAN><LI class=""><SPAN>}   </SPAN><LI class=alt><SPAN>--</SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span><span>   </span>
    </li>
    <li class="">
    <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>style</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
    </li>
    <li class="alt">
    <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>head</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
    </li>
    <li class=""><span> </span></li>
    <li class="alt">
    <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>body</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
    </li>
    <li class="">
    <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>form</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>enctype</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"multipart/form-data"</FONT></SPAN><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>method</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"post"</FONT></SPAN><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>name</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"upform"</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span>   </span>
    </li>
    <li class="alt"><span>  上传文件:   </span></li>
    <li class="">
    <span>  </span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>input</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>name</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"upfile"</FONT></SPAN><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>type</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"file"</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span>   </span>
    </li>
    <li class="alt">
    <span>  </span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>input</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>type</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"submit"</FONT></SPAN><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>value</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"上传"</FONT></SPAN><STRONG><FONT color=#006699><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
    </li>
    <li class="">
    <span>  允许上传的文件类型为:</span><span class="tag"><strong><font color="#006699"><?</FONT></STRONG></SPAN><SPAN>=implode(', ',$uptypes)</SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></font></strong></span><span>   </span>
    </li>
    <li class="alt">
    <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>form</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
    </li>
    <li class=""><span> </span></li>
    <li class="alt">
    <span></span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN>   </SPAN></SPAN><LI class=""><SPAN>if ($_SERVER['REQUEST_METHOD'] == 'POST')   </SPAN><LI class=alt><SPAN>{   </SPAN><LI class=""><SPAN>    if (!is_uploaded_file($_FILES["upfile"][tmp_name]))   </SPAN><LI class=alt><SPAN>    //是否存在文件   </SPAN><LI class=""><SPAN>    {   </SPAN><LI class=alt><SPAN>         echo "图片不存在!";   </SPAN><LI class=""><SPAN>         exit;   </SPAN><LI class=alt><SPAN>    }   </SPAN><LI class=""><SPAN> </SPAN><LI class=alt><SPAN>    $</SPAN><SPAN class=attribute><FONT color=#ff0000>file</FONT></SPAN><SPAN> = $_FILES["upfile"];   </SPAN></SPAN><LI class=""><SPAN>    if($max_file_size </SPAN><SPAN class=tag><STRONG><FONT color=#006699><</FONT></STRONG></SPAN><SPAN> $file["size"])   </SPAN></SPAN><LI class=alt><SPAN>    //检查文件大小   </SPAN><LI class=""><SPAN>    {   </SPAN><LI class=alt><SPAN>        echo "文件太大!";   </SPAN><LI class=""><SPAN>        exit;   </SPAN><LI class=alt><SPAN>    }   </SPAN><LI class=""><SPAN> </SPAN><LI class=alt><SPAN>    if(!in_array($file["type"], $uptypes))   </SPAN><LI class=""><SPAN>    //检查文件类型   </SPAN><LI class=alt><SPAN>    {   </SPAN><LI class=""><SPAN>        echo "文件类型不符!".$file["type"];   </SPAN><LI class=alt><SPAN>        exit;   </SPAN><LI class=""><SPAN>    }   </SPAN><LI class=alt><SPAN> </SPAN><LI class=""><SPAN>    if(!file_exists($destination_folder))   </SPAN><LI class=alt><SPAN>    {   </SPAN><LI class=""><SPAN>        mkdir($destination_folder);   </SPAN><LI class=alt><SPAN>    }   </SPAN><LI class=""><SPAN> </SPAN><LI class=alt><SPAN>    $</SPAN><SPAN class=attribute><FONT color=#ff0000>filename</FONT></SPAN><SPAN>=$file["tmp_name"];   </SPAN></SPAN><LI class=""><SPAN>    $</SPAN><SPAN class=attribute><FONT color=#ff0000>image_size</FONT></SPAN><SPAN> = </SPAN><SPAN class=attribute-value><FONT color=#0000ff>getimagesize</FONT></SPAN><SPAN>($filename);   </SPAN></SPAN><LI class=alt><SPAN>    $</SPAN><SPAN class=attribute><FONT color=#ff0000>pinfo</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>pathinfo</FONT></SPAN><SPAN>($file["name"]);   </SPAN></SPAN><LI class=""><SPAN>    $</SPAN><SPAN class=attribute><FONT color=#ff0000>ftype</FONT></SPAN><SPAN>=$pinfo['extension'];   </SPAN></SPAN><LI class=alt><SPAN>    $</SPAN><SPAN class=attribute><FONT color=#ff0000>destination</FONT></SPAN><SPAN> = $destination_folder.time().".".$ftype;   </SPAN></SPAN><LI class=""><SPAN>    if (file_exists($destination) && $overwrite != true)   </SPAN><LI class=alt><SPAN>    {   </SPAN><LI class=""><SPAN>        echo "同名文件已经存在了";   </SPAN><LI class=alt><SPAN>        exit;   </SPAN><LI class=""><SPAN>    }   </SPAN><LI class=alt><SPAN> </SPAN><LI class=""><SPAN>    if(!move_uploaded_file ($filename, $destination))   </SPAN><LI class=alt><SPAN>    {   </SPAN><LI class=""><SPAN>        echo "移动文件出错";   </SPAN><LI class=alt><SPAN>        exit;   </SPAN><LI class=""><SPAN>    }   </SPAN><LI class=alt><SPAN> </SPAN><LI class=""><SPAN>    $</SPAN><SPAN class=attribute><FONT color=#ff0000>pinfo</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>pathinfo</FONT></SPAN><SPAN>($destination);   </SPAN></SPAN><LI class=alt><SPAN>    $</SPAN><SPAN class=attribute><FONT color=#ff0000>fname</FONT></SPAN><SPAN>=$pinfo[basename];   </SPAN></SPAN><LI class=""><SPAN>    echo " </SPAN><STRONG><FONT color=#006699><SPAN class=tag><</SPAN><SPAN class=tag-name>font</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>color</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>red</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span>已经成功上传</span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>font</SPAN><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span></font></strong><span>文件名:  </span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>font</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>color</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>blue</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span>".$destination_folder.$fname."</span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>font</SPAN><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span></font></strong><span>";   </span>
    </li>
    <li class="alt"><span>    echo " 宽度:".$image_size[0];   </span></li>
    <li class=""><span>    echo " 长度:".$image_size[1];   </span></li>
    <li class="alt">
    <span>    echo "</span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span></font></strong><span> 大小:".$file["size"]." bytes";   </span>
    </li>
    <li class=""><span> </span></li>
    <li class="alt">
    <span>    if($</span><span class="attribute"><font color="#ff0000">watermark</font></span><span>==1)   </span>
    </li>
    <li class=""><span>    {   </span></li>
    <li class="alt">
    <span>        $</span><span class="attribute"><font color="#ff0000">iinfo</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">getimagesize</font></span><span>($destination,$iinfo);   </span>
    </li>
    <li class="">
    <span>        $</span><span class="attribute"><font color="#ff0000">nimage</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">imagecreatetruecolor</font></span><span>($image_size[0],$image_size[1]);   </span>
    </li>
    <li class="alt">
    <span>        $</span><span class="attribute"><font color="#ff0000">white</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">imagecolorallocate</font></span><span>($nimage,255,255,255);   </span>
    </li>
    <li class="">
    <span>        $</span><span class="attribute"><font color="#ff0000">black</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">imagecolorallocate</font></span><span>($nimage,0,0,0);   </span>
    </li>
    <li class="alt">
    <span>        $</span><span class="attribute"><font color="#ff0000">red</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">imagecolorallocate</font></span><span>($nimage,255,0,0);   </span>
    </li>
    <li class=""><span>        imagefill($nimage,0,0,$white);   </span></li>
    <li class="alt"><span>        switch ($iinfo[2])   </span></li>
    <li class=""><span>        {   </span></li>
    <li class="alt"><span>            case 1:   </span></li>
    <li class="">
    <span>            $</span><span class="attribute"><font color="#ff0000">simage</font></span><span> =</span><span class="attribute-value"><font color="#0000ff">imagecreatefromgif</font></span><span>($destination);   </span>
    </li>
    <li class="alt"><span>            break;   </span></li>
    <li class=""><span>            case 2:   </span></li>
    <li class="alt">
    <span>            $</span><span class="attribute"><font color="#ff0000">simage</font></span><span> =</span><span class="attribute-value"><font color="#0000ff">imagecreatefromjpeg</font></span><span>($destination);   </span>
    </li>
    <li class=""><span>            break;   </span></li>
    <li class="alt"><span>            case 3:   </span></li>
    <li class="">
    <span>            $</span><span class="attribute"><font color="#ff0000">simage</font></span><span> =</span><span class="attribute-value"><font color="#0000ff">imagecreatefrompng</font></span><span>($destination);   </span>
    </li>
    <li class="alt"><span>            break;   </span></li>
    <li class=""><span>            case 6:   </span></li>
    <li class="alt">
    <span>            $</span><span class="attribute"><font color="#ff0000">simage</font></span><span> =</span><span class="attribute-value"><font color="#0000ff">imagecreatefromwbmp</font></span><span>($destination);   </span>
    </li>
    <li class=""><span>            break;   </span></li>
    <li class="alt"><span>            default:   </span></li>
    <li class=""><span>            die("不支持的文件类型";   </span></li>
    <li class="alt"><span>            exit;   </span></li>
    <li class=""><span>        }   </span></li>
    <li class="alt"><span> </span></li>
    <li class=""><span>        imagecopy($nimage,$simage,0,0,0,0,$image_size[0],$image_size[1]);   </span></li>
    <li class="alt"><span>        imagefilledrectangle($nimage,1,$image_size[1]-15,80,$image_size[1],$white);   </span></li>
    <li class=""><span> </span></li>
    <li class="alt"><span>        switch($watertype)   </span></li>
    <li class=""><span>        {   </span></li>
    <li class="alt"><span>            case 1:   //加水印字符串   </span></li>
    <li class=""><span>            imagestring($nimage,2,3,$image_size[1]-15,$waterstring,$black);   </span></li>
    <li class="alt"><span>            break;   </span></li>
    <li class=""><span>            case 2:   //加水印图片   </span></li>
    <li class="alt">
    <span>            $</span><span class="attribute"><font color="#ff0000">simage1</font></span><span> =</span><span class="attribute-value"><font color="#0000ff">imagecreatefromgif</font></span><span>("xplore.gif";   </span>
    </li>
    <li class=""><span>            imagecopy($nimage,$simage1,0,0,0,0,85,15);   </span></li>
    <li class="alt"><span>            imagedestroy($simage1);   </span></li>
    <li class=""><span>            break;   </span></li>
    <li class="alt"><span>        }   </span></li>
    <li class=""><span> </span></li>
    <li class="alt"><span>        switch ($iinfo[2])   </span></li>
    <li class=""><span>        {   </span></li>
    <li class="alt"><span>            case 1:   </span></li>
    <li class=""><span>            //imagegif($nimage, $destination);   </span></li>
    <li class="alt"><span>            imagejpeg($nimage, $destination);   </span></li>
    <li class=""><span>            break;   </span></li>
    <li class="alt"><span>            case 2:   </span></li>
    <li class=""><span>            imagejpeg($nimage, $destination);   </span></li>
    <li class="alt"><span>            break;   </span></li>
    <li class=""><span>            case 3:   </span></li>
    <li class="alt"><span>            imagepng($nimage, $destination);   </span></li>
    <li class=""><span>            break;   </span></li>
    <li class="alt"><span>            case 6:   </span></li>
    <li class=""><span>            imagewbmp($nimage, $destination);   </span></li>
    <li class="alt"><span>            //imagejpeg($nimage, $destination);   </span></li>
    <li class=""><span>            break;   </span></li>
    <li class="alt"><span>        }   </span></li>
    <li class=""><span> </span></li>
    <li class="alt"><span>        //覆盖原上传文件   </span></li>
    <li class=""><span>        imagedestroy($nimage);   </span></li>
    <li class="alt"><span>        imagedestroy($simage);   </span></li>
    <li class=""><span>    }   </span></li>
    <li class="alt"><span> </span></li>
    <li class="">
    <span>    if($</span><span class="attribute"><font color="#ff0000">imgpreview</font></span><span>==1)   </span>
    </li>
    <li class="alt"><span>    {   </span></li>
    <li class="">
    <span>    echo "</span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span></font></strong><span>图片预览:</span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>br</SPAN><SPAN class=tag>></span></font></strong><span>";   </span>
    </li>
    <li class="alt">
    <span>    echo "</span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>img</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>src</FONT></SPAN><SPAN>="".$destination."" </SPAN><SPAN class=attribute><FONT color=#ff0000>width</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>".($image_size[0]*$imgpreviewsize)."</FONT></SPAN><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>height</FONT></SPAN><SPAN>=".($image_size[1]*$imgpreviewsize);   </SPAN></SPAN><LI class=""><SPAN>    echo " </SPAN><SPAN class=attribute><FONT color=#ff0000>alt</FONT></SPAN><SPAN>="图片预览:r文件名:".$destination."r上传时间:"</SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span>";   </span>
    </li>
    <li class="alt"><span>    }   </span></li>
    <li class=""><span>}   </span></li>
    <li class="alt">
    <span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span>   </span>
    </li>
    <li class="">
    <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>body</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
    </li>
    <li class="alt">
    <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>html</SPAN><SPAN class=tag>></span></font></strong><span>  </span>
    </li>
    </ol>

    The above is the specific code for adding watermark to pictures in PHP that we provide for you. I hope it will be useful to you. Friends help.


    www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446388.htmlTechArticleWhen we are building a website, we will encounter the need to add watermarks to the pictures uploaded by the website. If one by one Adding watermark manually is definitely very troublesome and impractical. So...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn