I was wondering how to go about adding soft focus (to blur an image a little bit) The way path.com does on the this page https://path.com/p/35p8q5 (the background image). I dont know if this is possible without using photoshop.
-
1Since Photoshop does it programmatically, so (in principle) can you. ;-) – Konrad Rudolph Jan 25 '12 at 17:11
-
LOL yes but i meant, if there are any libraries for php or python. Python preferably which would allow me to do such a thing – Adim Jan 25 '12 at 17:13
-
maybe this will help you http://stackoverflow.com/questions/1248866/php-gd-gaussian-blur-effect – Tim Jan 25 '12 at 17:14
-
Search more stack overflow... i found this in 5 sec -> http://stackoverflow.com/questions/1248866/php-gd-gaussian-blur-effect – Tudor Jan 25 '12 at 17:17
6 Answers
The go-to library (for PHP, Python …) is ImageMagick. Among other, this allows blurring.
Adapting the basic usage example:
<?php
header('Content-type: image/jpeg');
$image = new Imagick('image.jpg');
$image->blurImage(5, 3);
echo $image;
?>

- 530,221
- 131
- 937
- 1,214
It is a background image https://s3-us-west-1.amazonaws.com/images.path.com/photos2/d69d7c34-47c6-47ea-b7fd-8ff240690a50/web.jpg

- 1,780
- 4
- 20
- 31
If you look at the image that is the background of that page, you'll see that the image itself is blurred.
There is a 'dimmer' element overlay on top of it with a black background set to 25% opacity, but that doesn't blur or distort the picture.
It is probably possible to do what you are asking using the GD Library, although I believe that it's not really what you are looking to do.

- 24,395
- 4
- 69
- 96
A simple way to do it would be to take each pixel in the image and add up its surrounding pixels and get the average RGB value of the surrounding pixels. Then set the pixel to that average. Do this for each pixel

- 1,039
- 2
- 11
- 27
You can do this in Python with PIL. There's a filter
method on images, to which you can pass ImageFilter.BLUR
. You'll need to do this multiple times to get the amount of blurring shown in your sample.
def blur_multiple(im, amount=1):
result = im
for i in range(amount):
result = result.filter(ImageFilter.BLUR)
return result

- 299,747
- 42
- 398
- 622