3 $img = 'kubrickheader.jpg';
5 // If we don't have image processing support, redirect.
6 if ( ! function_exists('imagecreatefromjpeg') )
7 die(header("Location: kubrickheader.jpg"));
9 // Assign and validate the color values
11 $vars = array('upper'=>array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2'));
12 foreach ( $vars as $var => $subvars ) {
13 if ( isset($_GET[$var]) ) {
14 foreach ( $subvars as $index => $subvar ) {
15 $length = strlen($_GET[$var]) / 3;
16 $v = substr($_GET[$var], $index * $length, $length);
17 if ( $length == 1 ) $v = '' . $v . $v;
18 $$subvar = hexdec( $v );
19 if ( $$subvar < 0 || $$subvar > 255 )
28 list ( $r1, $g1, $b1, $r2, $g2, $b2 ) = array ( 105, 174, 231, 65, 128, 182 );
31 $im = imagecreatefromjpeg($img);
33 // Get the background color, define the rectangle height
34 $white = imagecolorat( $im, 15, 15 );
37 // Define the boundaries of the rounded edges ( y => array ( x1, x2 ) )
39 0 => array ( 25, 734 ),
40 1 => array ( 23, 736 ),
41 2 => array ( 22, 737 ),
42 3 => array ( 21, 738 ),
43 4 => array ( 21, 738 ),
44 177 => array ( 21, 738 ),
45 178 => array ( 21, 738 ),
46 179 => array ( 22, 737 ),
47 180 => array ( 23, 736 ),
48 181 => array ( 25, 734 ),
51 // Blank out the blue thing
52 for ( $i = 0; $i < $h; $i++ ) {
55 imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
58 // Draw a new color thing
59 for ( $i = 0; $i < $h; $i++ ) {
62 $r = ( $r2 - $r1 != 0 ) ? $r1 + ( $r2 - $r1 ) * ( $i / $h ) : $r1;
63 $g = ( $g2 - $g1 != 0 ) ? $g1 + ( $g2 - $g1 ) * ( $i / $h ) : $g1;
64 $b = ( $b2 - $b1 != 0 ) ? $b1 + ( $b2 - $b1 ) * ( $i / $h ) : $b1;
65 $color = imagecolorallocate( $im, $r, $g, $b );
66 if ( array_key_exists($i, $corners) ) {
67 imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
68 list ( $x1, $x2 ) = $corners[$i];
70 imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $color );
74 header("Content-Type: image/jpeg");
75 imagejpeg($im, '', 92);