<?php // :    $type = (isset($_GET['type']) &amp;&amp; $_GET['type'] == 'g') ? 'g' : 'v'; //  $height = (isset($_GET['h'])) ? abs((int)$_GET['h']) : 100; //  $width = (isset($_GET['w'])) ? abs((int)$_GET['w']) : 60; //  $start = (isset($_GET['s']) &amp;&amp; preg_match('#[0-9A-F]{6}#',$_GET['s'])) ? $_GET['s'] : '000000'; $end = (isset($_GET['e']) &amp;&amp; preg_match('#[0-9A-F]{6}#',$_GET['e'])) ? $_GET['e'] : 'FFFFFF'; // RGB   $start_r= hexdec(substr($start, 0, 2)); $start_g = hexdec(substr($start, 2, 2)); $start_b = hexdec(substr($start, 4, 2)); $end_r = hexdec(substr($end, 0, 2)); $end_g = hexdec(substr($end, 2, 2)); $end_b = hexdec(substr($end, 4, 2)); //  $image = imagecreate($width, $height); //     if($type == 'g'){ for($x=0; $x<$width; $x++){ $new_r = $start_r - intval(($start_r - $end_r) / $width * $x); $new_g = $start_g - intval(($start_g - $end_g) / $width * $x); $new_b = $start_b - intval(($start_b - $end_b) / $width * $x); $row_color = imagecolorresolve($image, $new_r, $new_g, $new_b); imageline($image, $x, 0, $x, $height, $row_color); } }else{ for($y=0; $y<$height; $y++){ $new_r = $start_r - intval(($start_r - $end_r) / $height * $y); $new_g = $start_g - intval(($start_g - $end_g) / $height * $y); $new_b = $start_b - intval(($start_b - $end_b) / $height * $y); $row_color = imagecolorresolve($image, $new_r, $new_g, $new_b); imageline($image, 0, $y, $width, $y, $row_color); } } header('Content-type: image/png'); imagepng($image); imagedestroy($image); //   :) ?>