PHP CodeIgnitor Image Manipulation Blur?

Hi experts,

I need to get a blur effect for an image handled with CodeIgnitor. I know how to resize, crop etc. in CI images but there is no action available inside the image manipulation class from CI to blur an image.

How could I get this done? Can I use/add a filter from dg2 to blur my image? (or any other library)

In the moment I do basically the following steps

$resize_config['image_library'] = 'gd2';
$resize_config['create_thumb'] = TRUE;
$resize_config['thumb_marker'] = false;
$resize_config['maintain_ratio'] = true;
$sourcePath = isset($config['upload_path'])?$config['upload_path']:$imgPath.'original/';
$sourcePath .= isset($new_file_name)?$new_file_name:$new_file;         
$destinationPath = $paths['path'];
$destinationPath .= isset($new_file_name)?$new_file_name:$new_file;
$resize_config['source_image']= $sourcePath;
$resize_config['width'] = $paths['width'];
$resize_config['height']= $paths['height'];
$resize_config['new_image'] = $destinationPath;
$resize_config['quality'] = '80%';

$CI->image_lib->clear();
$CI->image_lib->initialize($resize_config);
$CI->image_lib->resize();   

Open in new window


The result I am looking for is something like this http://tutorial9.s3.amazonaws.com/uploads/2008/06/lens-blur.jpg

Thanks for your tips in advance....
Oliver2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
What is the name / source of the image manipulation class?  Maybe it can be extended to add a blur method?
0
Oliver2000Author Commented:
I use right now only the internal image manipulation class from CodeIgnitor and in this case gd2.
0
Ray PaseurCommented:
OK, let me see if I can get it to take a blur method.  I won't be able to test completely since I do not have an instance of CI on this machine, but I may be able to make some progress with gd2.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Ray PaseurCommented:
Here is a pure PHP solution.  Try these links:
http://iconoun.com/demo/temp_oliver2000.php?blur=0
http://iconoun.com/demo/temp_oliver2000.php?blur=5
http://iconoun.com/demo/temp_oliver2000.php?blur=10
http://iconoun.com/demo/temp_oliver2000.php?blur=20

There may be a better filter for your exact needs, but IMG_FILTER_GAUSSIAN_BLUR is a decent place to start.
<?php // demo/temp_pierrek.php

/**
 * http://www.experts-exchange.com/questions/28700384/PHP-CodeIgnitor-Image-Manipulation-Blur.html
 *
 * http://php.net/manual/en/function.imagefilter.php
 */
error_reporting(E_ALL);

// ACQUIRE A TEST IMAGE RESOURCE
$url = 'http://iconoun.com/demo/images/image_600x374.png';
$img = imageCreateFromPNG($url);

// HOW MANY PASSESS OF THE BLUR FILTER?
$blur = !empty($_GET['blur']) ? (int)$_GET['blur'] : 0;

for ($x=1; $x<=$blur; $x++)
{
    imagefilter($img, IMG_FILTER_GAUSSIAN_BLUR);
}

// SHOW THE NEWLY BLURRED IMAGE
header('Content-type: image/png');
imagepng($img);

// RELEASE THE MEMORY
imagedestroy($img);

Open in new window

Next steps would be to figure out how to extend the CI->image_lib class.
https://ellislab.com/codeigniter/user-guide/libraries/image_lib.html

This seems to have some good information in the part about Extending Native Libraries
https://ellislab.com/codeigniter/user-guide/general/creating_libraries.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Oliver2000Author Commented:
This actually works flawless. Thank you Ray for this fast and easy solution.
0
Ray PaseurCommented:
Glad to help!  Thanks for the points and thanks for using E-E-, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.