note 109809 added to function.imagefilter
| From: | cookie at backbone dot sk | Date: | Thu, 23 Aug 2012 13:11:28 +0000 |
| Subject: | note 109809 added to function.imagefilter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190191@lists.php.net to get a copy of this message | ||
a function to create nice vignette effect:
<?php
function vignette($im){
global $width, $height;
$width = imagesx($im);
$height = imagesy($im);
function effect($x, $y, &$rgb){
global $width, $height;
$sharp = 0.4; // 0 - 10 small is sharpnes,
$level = 0.7; // 0 - 1 small is brighter
$l = sin(M_PI / $width * $x) * sin(M_PI / $height * $y);
$l = pow($l, $sharp);
$l = 1 - $level * (1 - $l);
$rgb['red'] *= $l;
$rgb['green'] *= $l;
$rgb['blue'] *= $l;
}
for($x = 0; $x < imagesx($im); ++$x){
for($y = 0; $y < imagesy($im); ++$y){
$index = imagecolorat($im, $x, $y);
$rgb = imagecolorsforindex($im, $index);
effect($x, $y, $rgb);
$color = imagecolorallocate($im, $rgb['red'], $rgb['green'],
$rgb['blue']);
imagesetpixel($im, $x, $y, $color);
}
}
return(true);
}
$im = imagecreatefromjpeg('cars7_134.jpg');
if($im and vignette($im)){
header('Content-Type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
}else{
echo 'Vignette failed.';
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 86.110.226.110
----
Manual Page -- http://www.php.net/manual/en/function.imagefilter.php
Edit -- https://master.php.net/note/edit/109809
Del: integrated -- https://master.php.net/note/delete/109809/integrated
Del: useless -- https://master.php.net/note/delete/109809/useless
Del: bad code -- https://master.php.net/note/delete/109809/bad+code
Del: spam -- https://master.php.net/note/delete/109809/spam
Del: non-english -- https://master.php.net/note/delete/109809/non-english
Del: in docs -- https://master.php.net/note/delete/109809/in+docs
Del: other reasons-- https://master.php.net/note/delete/109809
Reject -- https://master.php.net/note/reject/109809
Search -- https://master.php.net/manage/user-notes.php