php给图片添文字水印
php给图片加文字水印
<?php /*给图片加文字水印的方法*/$dst_path = 'http://f4.topitme.com/4/15/11/1166351597fe111154l.jpg';$dst = imagecreatefromstring(file_get_contents($dst_path));/*imagecreatefromstring()--从字符串中的图像流新建一个图像,返回一个图像标示符,其表达了从给定字符串得来的图像图像格式将自动监测,只要php支持jpeg,png,gif,wbmp,gd2.*/$font = './t1.ttf';$black = imagecolorallocate($dst, 0, 0, 0);imagefttext($dst, 20, 0, 10, 30, $black, $font, 'Hello world!');/*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);?>
钟志远 江苏南京 904727147
版权声明:本文为博主原创文章,未经博主允许不得转载。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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.

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

In this guide, we will learn more about the "type" 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 "type" 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

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.

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.

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

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.
