Change the Brightness of the Picture
Current Image:
Select Brightness ( 0 = No Change, 10 = Brightest)
SLAVE CODE FOLLOWS
<?php
$brightness = $_GET['br'];
$image = imagecreatefromjpeg("fluffycat.jpg");
imagetruecolortopalette($image, true, 256);
$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;
}
?>