| Ѷ̳ | | | һת | Ͷ
λãվ > > PHP̳ > PHPͼƬˮӡЧʵ

PHPͼƬˮӡЧʵ

һ(LieHuo.Net)̳ PHPͼƬˮӡЧʵ

Ϊõݣ
<?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("06.png","123.png","07.png",370,285,150,15);

?>
    Ķ