 <p>I haven't really done much image-processing, so this is just a long shot, but couldn't you do something like this:</p> <pre><code>function addPercentageToNumber($number, $minPercentage, $maxPercentage) { return $number + rand( ($number / 100) * $minPercentage, ($number / 100) * $maxPercentage ); } // Base color $r2 = rand(0, 255); // Add 10-20% $r2 = addPercentageToNumber($r2, 10, 20); </code></pre> <p>You would also need to add some code to handle what happens when a result would be <code>&gt;255</code> and so on. Hope this helps you a little atleast. :-)</p>