A pure GD ImageBlur. More at http://www.puremango.co.uk
<?
function myImageBlur($im)
{
// w00t. my very own blur function
$width = imagesx($im);
$height = imagesy($im);
$temp_im = ImageCreateTrueColor($width,$height);
$bg = ImageColorAllocate($temp_im,150,150,150);
// preserves transparency if in orig image
ImageColorTransparent($temp_im,$bg);
// fill bg
ImageFill($temp_im,0,0,$bg);
// the higher, the more blurred (no impact on speed)
$distance = 1;
// blur by merging with itself at different x/y offsets:
ImageCopyMerge($temp_im, $im, 0, 0, 0, $distance, $width, $height-$distance, 70);
ImageCopyMerge($im, $temp_im, 0, 0, $distance, 0, $width-$distance, $height, 70);
ImageCopyMerge($temp_im, $im, 0, $distance, 0, 0, $width, $height, 70);
ImageCopyMerge($im, $temp_im, $distance, 0, 0, 0, $width, $height, 70);
// remove temp image
ImageDestroy($temp_im);
return $im;
}
?>
Imagick::blurImage
(PECL imagick 2.0.0)
Imagick::blurImage — Adds blur filter to image
Description
bool Imagick::blurImage
( float $radius
, float $sigma
[, int $channel
] )
Warning
This function is currently not documented; only its argument list is available.
Adds blur filter to image. Optional third parameter to blur a specific channel.
Parameters
- radius
-
Blur radius
- sigma
-
Standard deviation
- channel
-
The Channeltype constant. When not supplied, all channels are blurred.
Return Values
Returns TRUE on success.
Errors/Exceptions
Throws ImagickException on error.
Examples
Example #1 Using Imagick::blurImage():
Blur an image, then display to the browser.
<?php
header('Content-type: image/jpeg');
$image = new Imagick('test.jpg');
$image->blurImage(5,3);
echo $image;
?>
See Also
- Imagick::adaptiveBlurImage() - Adds adaptive blur filter to image
- Imagick::motionBlurImage() - Simulates motion blur
- Imagick::radialBlurImage() - Radial blurs an image
Imagick::blurImage
puremango dot co dot uk at gmail dot com
19-Apr-2009 03:00
19-Apr-2009 03:00
