Change the Brightness of the Picture


Current Image:

Fluffy Cat

Select Brightness ( 0 = No Change, 10 = Brightest)

Brightness Determination:

0   1   2   3   4   5  






SLAVE CODE FOLLOWS <?php
$brightness 
$_GET['br'];

$image imagecreatefromjpeg("fluffycat.jpg");

imagetruecolortopalette($imagetrue256);

$totalColors imagecolorstotal($image);

for (
$index 0$index $totalColors$index++)
{
    
// $RGB is an array
    
$RGB imagecolorsforindex($image$index);
    
$red adjustBightness($RGB['red'], $brightness);
    
$green adjustBightness($RGB['green'], $brightness);
    
$blue adjustBightness($RGB['blue'], $brightness);
    
imagecolorset($image$index$red$green$blue);
}
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);

function 
adjustBightness($color$brightness)
{
    
// determine the color brightness
    
$color += (($brightness 10) * 255);

    
// make sure the color value does not exceed 255
    
$color = ($color 255) ? 255 $color;
    return 
$color;
}

?>