php 图片上添加透明度渐变的效果

yipeiwu_com6年前PHP代码库

复制代码 代码如下:

<?php
////$strimgsrc = file_get_contents("/zb_users/upload/202003/e4lf1fxwbqa.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);
?>

相关文章

Ubuntu12下编译安装PHP5.3开发环境

最近项目遇到一个坑爹的事情,一个源码必须使用PHP5.3,但是现在Ubuntu上自带的版本是5.4,降级之后会出各种奇怪的问题,最后没办法,只能一步步在Ubuntu12.04server...

php文件上传简单实现方法

本文实例讲述了php文件上传的简单实现方法。分享给大家供大家参考。具体如下: 文件1:index.php 复制代码 代码如下:<form enctype="multipart/fo...

PHP中soap用法示例【SoapServer服务端与SoapClient客户端编写】

本文实例讲述了PHP中soap用法。分享给大家供大家参考,具体如下: 一、首先要设置服务器环境 修改php.ini 得添加extension=php_soap.dll (加载soap 内...

php通用检测函数集合第1/3页

<?  //【警告】:未经许可请勿随便修改  //-------------------------------------------------------...

深入理解PHP之源码目录结构与功能说明

本文讲述了PHP源码目录结构与功能说明。分享给大家供大家参考,具体如下: PHP之所以能在web开发语言中排名靠前,不仅仅是因为语法简单,上手容易。我个人认为更多是因为其语言本身的:模块...