Add watermark to images using PHP code_PHP tutorial

WBOY
Release: 2016-07-13 09:48:03
Original
925 people have browsed it

Use PHP code to add watermark to pictures

This article mainly introduces the relevant information about using PHP code to add watermark to pictures. Friends who need it can refer to it

First find a picture, rename it face.jpeg, and create watermark.php:

 ?

1

2

3

4

5

6

7

8

9

10

11

12

/**

* Created by PhpStorm.

* User: Administrator

* Date: 2015/6/29

* Time: 22:27

*/

$img = imagecreatefromjpeg('face.jpeg');//根据已有的JPG创建image

header('Content-type:image/jpeg');//设置mime type

imagestring($img,5,5,5,'Vito-L',imagecolorallocate($img,255,0,0));//生成水印,imagestring(图片,字体,位置x,位置y,字符串,颜色)

imagejpeg($img);//输出图片

//整幅图像的左上角为 0,0

1

2
3

4

5

6

8 9 10 11 12
/** * Created by PhpStorm. * User: Administrator * Date: 2015/6/29 * Time: 22:27 */ $img = imagecreatefromjpeg('face.jpeg');//Create image based on existing JPG header('Content-type:image/jpeg');//Set mime type imagestring($img,5,5,5,'Vito-L',imagecolorallocate($img,255,0,0));//Generate watermark, imagestring(picture, font, position x, position y, string, color) imagejpeg($img);//Output image //The upper left corner of the entire image is 0, 0
The effect is as follows: The above is the entire content of this article, I hope you all like it. http://www.bkjia.com/PHPjc/1025318.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1025318.htmlTechArticleUsing PHP code to watermark images. This article mainly introduces the relevant information about using PHP code to add watermark to images. Friends in need can find a picture for reference first, rename it face.jpeg, and create...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template