Home Backend Development PHP Tutorial php给图片添文字水印

php给图片添文字水印

Jun 13, 2016 pm 12:23 PM
break quot type

php给图片加文字水印

<?php /*给图片加文字水印的方法*/$dst_path = &#39;http://f4.topitme.com/4/15/11/1166351597fe111154l.jpg&#39;;$dst = imagecreatefromstring(file_get_contents($dst_path));/*imagecreatefromstring()--从字符串中的图像流新建一个图像,返回一个图像标示符,其表达了从给定字符串得来的图像图像格式将自动监测,只要php支持jpeg,png,gif,wbmp,gd2.*/$font = &#39;./t1.ttf&#39;;$black = imagecolorallocate($dst, 0, 0, 0);imagefttext($dst, 20, 0, 10, 30, $black, $font, &#39;Hello world!&#39;);/*imagefttext($img,$size,$angle,$x,$y,$color,$fontfile,$text)$img由图像创建函数返回的图像资源size要使用的水印的字体大小angle(角度)文字的倾斜角度,如果是0度代表文字从左往右,如果是90度代表从上往下x,y水印文字的第一个文字的起始位置color是水印文字的颜色fontfile,你希望使用truetype字体的路径*/list($dst_w,$dst_h,$dst_type) = getimagesize($dst_path);/*list(mixed $varname[,mixed $......])--把数组中的值赋给一些变量像array()一样,这不是真正的函数,而是语言结构,List()用一步操作给一组变量进行赋值*//*getimagesize()能获取到什么信息?getimagesize函数会返回图像的所有信息,包括大小,类型等等*/switch($dst_type){    case 1://GIF        header("content-type:image/gif");        imagegif($dst);        break;    case 2://JPG        header("content-type:image/jpeg");        imagejpeg($dst);        break;    case 3://PNG        header("content-type:image/png");        imagepng($dst);        break;    default:        break;    /*imagepng--以PNG格式将图像输出到浏览器或文件    imagepng()将GD图像流(image)以png格式输出到标注输出(通常为浏览器),或者如果用filename给出了文件名则将其输出到文件*/}imagedestroy($dst);?>
Copy after login

钟志远  江苏南京  904727147

版权声明:本文为博主原创文章,未经博主允许不得转载。

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the uses of the Type keyword in Go? What are the uses of the Type keyword in Go? Sep 06, 2023 am 09:58 AM

The usage of the Type keyword in Go includes defining new type aliases or creating new structure types. Detailed introduction: 1. Type alias. Use the "type" keyword to create an alias for an existing type. This alias does not create a new type, but only provides a new name for the existing type. Type aliases can improve code. The readability of the code makes the code clearer; 2. Structure type. Use the "type" keyword to create a new structure type. The structure is a composite type that can be used to define custom types containing multiple fields. etc.

Solve Ubuntu mounting mobile hard disk error: unknown file system type exfat Solve Ubuntu mounting mobile hard disk error: unknown file system type exfat Jan 05, 2024 pm 01:18 PM

An error occurs when ubuntu mounts a mobile hard disk: mount: unknownfilesystemtype'exfat'. The processing method is as follows: Ubuntu13.10 or install exfat-fuse: sudoapt-getinstallexfat-fuseUbuntu13.04 or below sudoapt-add-repositoryppa:relan/exfatsudoapt-getupdatesudoapt-getinstallfuse- exfatCentOS Linux mount exfat format USB disk error solution to load extfa in CentOS

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Linux type command Linux type command Mar 20, 2024 pm 05:06 PM

In this guide, we will learn more about the &quot;type&quot; command in Linux. Prerequisites: To perform the steps demonstrated in this guide, you need the following components: A properly configured Linux system. See how to create a LinuxVM for testing and learning purposes. Basic understanding of the command line interface The Type command in Linux is different from other Linux-specific commands (for example: ls, chmod, shutdown, vi, grep, pwd, etc.). The &quot;type&quot; command is a built-in Bash function that is displayed as an argument. Information about the command type provided. $type In addition to Bash, other shells (Zsh, Ksh, etc.) also come with

Let's talk about not using break in PHP switch statement Let's talk about not using break in PHP switch statement Mar 20, 2023 pm 04:55 PM

It is very common to use switch statements to select multiple branches in PHP. Usually, a break statement is used to exit the switch statement after each branch. However, there are situations where we do not want to use the break statement. This article will introduce the situation of not using break in the PHP switch statement.

What is the usage of break in php What is the usage of break in php Jan 31, 2023 pm 07:33 PM

In PHP, break is used to jump out of the current syntax structure and execute the following statements; it can be used in statements such as switch, for, while, and do while. It can terminate the code of the loop body and jump out of the current loop immediately, and execute the following statements after the loop. code. The break statement can take a parameter n, which represents the number of levels to jump out of the loop. If you want to jump out of multiple loops, you can use n to represent the number of levels to jump out of. If there is no parameter, the default is to jump out of the current loop.

What is the function of break keyword in Java? What is the function of break keyword in Java? Apr 23, 2023 am 10:13 AM

Note 1. The function of break is to jump out of the current loop block (for, while, dowhile) or program block (switch). 2. The function of the loop block is to jump out of the loop body currently in the loop. The function of the program block is to interrupt and compare the next case condition. Use break in a switch statement to terminate the switch statement. When break is used in a loop, it breaks out of the loop. There is no point in using break elsewhere. Example intsum=0;inti;for(i=1;i

What information is required when registering a Deepseek account? What information is required when registering a Deepseek account? Mar 12, 2025 pm 02:33 PM

Required information: 1. Email registration; 2. Mobile phone number registration; 3. Third-party social platform registration. After successful registration, you usually need to fill in some basic personal information, such as nickname, gender, birthday, etc.

See all articles