How to pixelate part of image using ImageMagick?
I'm trying to figure out a way to pixelate only part of an image but no success so far.
Currently I'm following the following this tutorial: http://www.mutinydesign.co.uk/free-scripts/live-photo-blurring-script/
Using the jQuery plugin "imgAreaSelect" so that users can select part of the picture from the UI. Then the click 'pixelate'. This then makes an ajax call to the pixelate function written in php for imagemagick. The pixelate function looks like this:
<?php
$x1 = $_GET['x1'];
$y1 = $_GET['y1'];
$x2 = $_GET['x2'];
$y2 = $_GET['y2'];
$inputImage = $_GET['inputImage'];
$outputImage = 'output_'.$_GET['inputImage'];
exec( "convert {$inputImage} \( +clone -scale 20% -scale 500% \) \
\( +clone -gamma 0 -fill white \
-draw 'rectangle {$x1},{$y1} {$x2},{$y2}' -blur 10x4 \) \
-composite {$outputImage}" );
echo $outputImage;
?>
This does work but it pixelates the whole image and not just the par开发者_如何学运维t selected. Any ideas or suggestions appreciated. Has anyone been able to accomplish something similar?
What you need to do is split the image into two variables, duplicating it. Then you crop one image in around the desired location. Pixel it up, then plop it right back onto the other image in the same place it was.
Then output it.
You'll have a sub-section of the image with blur, and the rest clear.
精彩评论