3

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.

Adim
  • 811
  • 2
  • 10
  • 25
  • 1
    Since 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 Answers6

4

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;
?>
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
0

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.

Jeff Lambert
  • 24,395
  • 4
  • 69
  • 96
0

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

theDazzler
  • 1,039
  • 2
  • 11
  • 27
0

I noticed you included python so I would suggest looking into pil. I've only used it a bit, but it appears that there is a module that can blur images.

krs1
  • 1,125
  • 7
  • 16
0

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
Mark Ransom
  • 299,747
  • 42
  • 398
  • 622