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/
目前我正在遵循以下教程: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:
使用jQuery插件“imgAreaSelect”,以便用户可以从UI中选择部分图片。然后点击'pixelate'。然后对phpmagick编写的pixelate函数进行ajax调用。像素化函数如下所示:
<?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 part selected. Any ideas or suggestions appreciated. Has anyone been able to accomplish something similar?
这确实有效,但它会对整个图像进行像素化,而不仅仅是选择的部分。任何想法或建议表示赞赏。有没有人能够完成类似的事情?
1 个解决方案
#1
1
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.
你将有一个模糊的图像的子部分,其余部分清晰。
#1
1
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.
你将有一个模糊的图像的子部分,其余部分清晰。