久久久久无码精品,四川省少妇一级毛片,老老熟妇xxxxhd,人妻无码少妇一区二区

PHP圖片加水印十分簡(jiǎn)單的代碼

時(shí)間:2020-11-20 14:55:50 PHP 我要投稿

PHP圖片加水印十分簡(jiǎn)單的代碼

  PHP圖片加水印十分簡(jiǎn)單的代碼

  文字水印:

  復(fù)制代碼 代碼如下:

  $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); //畫(huà)一矩形并填充

  // 把字符串寫(xiě)在圖像左上角

  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提供了很多函數(shù):例如:imagecopymerge,imagecopyresized

【PHP圖片加水印十分簡(jiǎn)單的代碼】相關(guān)文章:

1.PHP 透明水印生成代碼參考

2.php使用imagick給圖片加水印的方法

3.PHP代碼優(yōu)化技巧

4.PHP調(diào)用的C代碼整理

5.如何閱讀php源代碼

6.php如何過(guò)濾危險(xiǎn)html代碼

7.php樹(shù)型類實(shí)例代碼

8.將php實(shí)現(xiàn)過(guò)濾UBB代碼