$g) {$h+=360;} break; case $g: $h=60*(($b-$r)/$d+2); break; case $b: $h=60*(($r-$g)/$d+4); break; } } return array(round($h,3),round($s,3),round($l,3)); } function HSL2RGB($h,$s,$l) { $c=(1-abs(2*$l-1))*$s; $x=$c*(1-abs(fmod(($h/60),2)-1)); $m=$l-($c/2); if($h<60) { $r=$c; $g=$x; $b=0; } else if($h<120) { $r=$x; $g=$c; $b=0; } else if ($h<180) { $r=0; $g=$c; $b=$x; } else if($h<240) { $r=0; $g=$x; $b=$c; } else if ($h<300) { $r=$x; $g=0; $b=$c; } else { $r=$c; $g=0; $b=$x; } $r=($r+$m)*255; $g=($g+$m)*255; $b=($b+$m)*255; return array(floor($r),floor($g),floor($b)); } function vibrance($S,$L) { //$S+=0.3*pow(20,-pow($S-0.5,2)*5); //$S+=0.5-abs($S-0.5); //$S=$S/1.5+0.333333; //$kL=1-2*abs($L-0.5); $kL=1-2*abs($L-0.5); $S+=(0.5-abs($S-0.5))*$kL; return $S; } $img=imagecreatefrompng('in.png'); $width=imagesx($img); $height=imagesy($img); for($y=0;$y<$height;$y++) { for($x=0;$x<$width;$x++) { $rgb=ImageColorAt($img,$x,$y); $R=($rgb>>16) & 0xFF; $G=($rgb>>8) & 0xFF; $B=$rgb & 0xFF; list($H,$S,$L)=RGB2HSL($R,$G,$B); $S=vibrance($S,$L); list($R,$G,$B)=HSL2RGB($H,$S,$L); $color=imagecolorallocate($img,$R,$G,$B); imagesetpixel($img,$x,$y,$color); } } header('Content-Type: image/png'); imagepng($img); imageDestroy($img); ?>