PHP GD库:实现从上到下的图片渐变效果
$imgsrc = imagecreatefromstring(file_get_contents('image.jpg')); $imgsrcw = imagesx($imgsrc); $imgsrch = imagesy($imgsrc); $height = 1080; $x1 = 0; $x2 = $imgsrcw - $x1 - 20; $y1 = 0; $y2 = $height; $steps = $y2 - $y1; for($i = 0; $i < $steps; $i ++) { $alphay = round($i/($steps/127))+60; if($alphay >= 128) $alphay = 127; $alpha = imagecolorallocatealpha($imgsrc, 255, 255, 255, $alphay); imagefilledrectangle($imgsrc, $x1, ($i+$y1), $x2, ($i+$y1+1), $alpha); } header('content-type: image/jpeg'); imagejpeg($imgsrc,'09.jpg'); imagedestroy($imgsrc);
原文地址: https://www.cveoy.top/t/topic/kwf9 著作权归作者所有。请勿转载和采集!