search
Homephp教程php手册PHP图片水印效果的实例代码

PHP图片水印效果的实例代码

Jun 13, 2016 am 11:38 AM
phpcodepictureExampleEffectTutorialwatermarkof

  帮客之家(www.Bkjia.com)教程 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);

?>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools