php 圖片上添加透明度漸變的效果
更新時間:2009年06月29日 23:26:07 作者:
今天因為臨時需要,要動態(tài)的在圖片上添加透明度漸變的效果,在網上找了半天沒有相應功能的算法....
復制代碼 代碼如下:
<?php
////$strimgsrc = file_get_contents("http://127.0.0.1/5307754.jpg");
////$imgsrc = imagecreatefromstring($strimgsrc);
$imgsrc = imagecreatefromjpeg("5307754.jpg");
$imgsrcw = imagesx($imgsrc);
$imgsrch = imagesy($imgsrc);
$width = 30;
$x1 = 2;
$x2 = $imgsrcw - $x1 - 20;
$y1 = ($imgsrch - $width) - 2;
$y2 = $y1 + $width;
$steps = $x2 - $x1;
for($i = 0; $i < $steps; $i ++)
{
$alphax = round($i/($steps/127))+60;
if($alphax >= 128)
$alphax = 127;
$alpha = imagecolorallocatealpha($imgsrc, 255, 255, 255, $alphax);
imagefilledrectangle($imgsrc, ($i+$x1), $y1, ($i+$x1+1), $y2, $alpha);
}
header('content-type: image/jpeg');
imagejpeg($imgsrc);
imagedestroy($imgsrc);
?>
相關文章
PHP Class SoapClient not found解決方法
這篇文章主要介紹了PHP Class SoapClient not found解決方法,需要的朋友可以參考下2018-01-01php中base64_decode與base64_encode加密解密函數(shù)實例
這篇文章主要介紹了php中base64_decode與base64_encode加密解密函數(shù),實例分析了base64加密解密函數(shù)的具體用法,具有一定的實用價值,需要的朋友可以參考下2014-11-11php 從指定數(shù)字中獲取隨機組合的簡單方法(推薦)
下面小編就為大家?guī)硪黄猵hp 從指定數(shù)字中獲取隨機組合的簡單方法(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-04-04詳解WordPress開發(fā)中wp_title()函數(shù)的用法
這篇文章主要介紹了WordPress開發(fā)中wp_title()函數(shù)的用法,wp_title可以用來顯示文章標題和分類名稱等,需要的朋友可以參考下2016-01-01PHP 5.3.1 安裝包 VC9 VC6不同版本的區(qū)別是什么
php官網提供了四個版本,VC9 x86 Non Thread Safe、VC9 x86 Thread Safe、VC6 x86 Non Thread Safe、VC6 x86 Thread Safe,大家看完這篇文章就知道應該選擇什么樣的版本了。2010-07-07