php 文字水印

2021-07-25 19:49:08 字數 995 閱讀 9565

<?php

/*給加文字水印的方法*/

$dst_path = '';

$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)

imagedestroy($dst);

?>

php畫布,新增字元 文字水印

用到的函式 建立 img imagecreate 500,500 建立完成我們需要向資源填加顏色,需要使用到函式 顏色變數 imagecolorallocate resource 資源 int 紅 int 綠 int 藍 將顏色新增到背景進行填充 imagefilledrectangle resou...

PHP平鋪水印

bigimgpath logo.png 原圖 logo logo2.png 水印 im imagecreatefromstring file get contents bigimgpath 獲取水印源 watermark imagecreatefromstring file get contents...

PHP 水印處理

1.開啟伺服器或網路中存在的gif,jpeg,png,wbmp格式影象 imagecreatefromjpeg imagecreatefrompng imagecreatefromgif imagecreatefrombwmp header content type image jpeg color...