国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

一個簡單實用的php加圖片水印函數

2024-05-04 23:05:40
字體:
來源:轉載
供稿:網友

以下是引用片段:
以下為引用的內容:
<?php
  
 //$backfile:  背景圖
 //$copyfile:  待拷貝的圖 
 //$resultfile:  生成文件保存地址
 //$copytox:  拷貝到背景圖上的x坐標
 //$copytoy:  拷貝到背景圖上的y坐標
 //$copytowidth: 把待拷貝的圖變為多寬
 //$copytoheight: 把待拷貝的圖變為多高
 function imgmerge($backfile,$copyfile,$resultfile,$copytox,$copytoy,$copytowidth,$copytoheight)
 {
  //如果文件名后綴不是"png"則返回""
  if (getfileupperext($backfile) != "png")
   return "";
  //如果文件名后綴不是"png"則返回""
  if (getfileupperext($copyfile) != "png")
   return "";
  $backimg = imagecreatefrompng($backfile);
  //如果值沒有設置,則返回""
  if (!isset($backimg ))
  {
   return "";
  }
  $backimgx = imagesx($backimg);
  $backimgy = imagesx($backimg);
  
  $copyimg = imagecreatefrompng($copyfile);
  //如果值沒有設置,則返回""
  if (!isset($copyimg ))
  {
   return "";
  }
  $copyresizeimg = imageresize($copyimg, $copytowidth, $copytoheight);
  
  $bcopy = imagecopy($backimg,$copyresizeimg,$copytox,$copytoy,0,0,$copytowidth,$copytoheight);
  if (!$bcopy )
  {
   return "";
  }
  imagealphablending($backimg, true);
  imagesavealpha($backimg, true);
  
  if (!imagepng($backimg,$resultfile))
   return "";
  return $resultfile;
 }
 
 //獲得傳入文件的文件名
 function getfileupperext($fullfile)
 {
  if (!file_exists($fullfile)) 
   return "";
  $pathinfo = pathinfo($fullfile );  
  return strtoupper($pathinfo[’extension’]);  
 }
 
 function imageresize($rimage, $iwidth, $iheight) 
 {
  $icanvas = imagecreate($iwidth, $iheight);
  $iwidthx  = imagesx($rimage);
  $iheighty = imagesy($rimage);
  imagecopyresampled($icanvas, $rimage, 0, 0, 0, 0, $iwidth, $iheight, $iwidthx, $iheighty);
  return $icanvas;
 }
 
 imgmerge("backimg.png","copyimg.png","imgmerge.png",3,3,30,30);
?> 



收集最實用的網頁特效代碼!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿勒泰市| 太仆寺旗| 湘西| 盐边县| 微山县| 喀什市| 沛县| 金坛市| 和田县| 鄢陵县| 海原县| 潢川县| 新和县| 清苑县| 晋州市| 岚皋县| 华亭县| 罗定市| 霞浦县| 紫阳县| 鄂伦春自治旗| 繁峙县| 温宿县| 宜春市| 罗城| 手游| 东辽县| 西充县| 麻栗坡县| 永靖县| 昭平县| 五指山市| 临朐县| 横山县| 曲阜市| 文水县| 扎赉特旗| 金坛市| 慈溪市| 诸城市| 新建县|