PHP圖片浮水印效果的執行個體代碼_PHP教程

來源:互聯網
上載者:User
   幫客之家(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);

?>

http://www.bkjia.com/PHPjc/364319.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/364319.htmlTechArticle烈火網(LieHuo.Net)教程 PHP圖片浮水印效果的執行個體代碼 以下為引用的內容: ?php //$backFile: 背景圖 //$copyFile: 待拷貝的圖 //$resultFile: 組建檔案...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.