色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php圖片加水印原理(超簡單的實例代碼)

文字水印:
復制代碼 代碼如下:
$w = 80;
$h = 20;
$im = imagecreatetruecolor($w,$h);
$textcolor = imagecolorallocate($im, 123, 12, 255);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $grey); //畫一矩形并填充

// 把字符串寫在圖像左上角
imagestring($im, 3, 2, 3, "Hello world!", $textcolor);

// 輸出圖像
header("Content-type: image/jpeg");
imagejpeg($im);
imagedestroy($im);

圖片水印

$groundImg = "DSC05940.jpeg";
$groundInfo = getimagesize($groundImg);
$ground_w = $groundInfo[0];
//print_r($groundInfo);
$ground_h = $groundInfo[1];
switch($groundInfo[2]){
case 1:
$ground_im = imagecreatefromgif($groundImg);
break;
case 2:
$ground_im = imagecreatefromjpeg($groundImg);
break;
case 3:
$ground_im = imagecreatefrompng($groundImg);
break;
}

$waterImg = "DSC05949.jpeg";
$imgInfo =getimagesize($waterImg);
$water_w = $imgInfo[0];
$water_w = $imgInfo[1];

switch($imgInfo[2]){
case 1:
$water_im = imagecreatefromgif($waterImg);
break;
case 2:
$water_im = imagecreatefromjpeg($waterImg);
break;
case 3:
$water_im = imagecreatefrompng($waterImg);
break;
}
imagecopy($ground_im,$water_im,100,100,0,0,500,500);
header("Content-type: image/jpeg");

imagejpeg($ground_im);

合并圖片php提供了很多函數:例如:imagecopymerge,imagecopyresized

php技術php圖片加水印原理(超簡單的實例代碼),轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 普宁市| 玉树县| 鹿泉市| 岳普湖县| 天津市| 屏南县| 海阳市| 耒阳市| 山阴县| 广饶县| 宝山区| 彰化市| 宜春市| 任丘市| 仪征市| 秦安县| 沽源县| 长汀县| 和平县| 明星| 颍上县| 应城市| 仙居县| 明光市| 闽清县| 广宗县| 杭锦后旗| 北京市| 凤山市| 寿光市| 大姚县| 临颍县| 贵南县| 泰和县| 孝感市| 凌云县| 麟游县| 晋宁县| 宜川县| 阳春市| 吴川市|