Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blur part of image in Imagemagick

What convert command do I use to blur part of an image. For now I am using

convert source.jpg -fill white  -draw "polyline 671,395 665,356 812,331 818,370"  result.jpg

It creates white four points shape on the image, but I need blur all of this part of the image.

Thanks!

like image 632
Dima Magunov Avatar asked Nov 01 '17 22:11

Dima Magunov


People also ask

How do you blur certain parts of a picture?

Go to Edit Image in the top toolbar and locate the Blur option under Tools or search for it in the search bar. Use the Auto option to blur your entire image, or select Blur to brush the area you want to blur out. You can also erase the blur by using the Restore brush option.

How do I blur part of an image in CSS?

So, here's how to create a background blur using the backdrop-filter CSS property. backdrop-filter: blur(5px); That's it.

How do you add a blur filter?

If you want to blur the entire image choose Filter > Blur > Gaussian Blur... Adjust the radius to add more or less blur to the image. Then click "OK".


2 Answers

In ImageMagick, you can use any mask to limit the blur.

Create a black and white mask image: black inside your quadrilateral and white elsewhere of the size of your image. Then use that as a mask for doing blurring. See http://www.imagemagick.org/Usage/masking/#read_mask.

Input:

enter image description here

(Unix syntax)

convert \
logo.jpg \
\( -clone 0 -fill white -colorize 100 -fill black \
-draw "polygon 332,180 427,105 481,238 399,279" \
-alpha off -write mpr:mask +delete \) \
-mask mpr:mask -blur 0x5 +mask logo_blur.jpg

Blurred Result

enter image description here

like image 131
fmw42 Avatar answered Sep 22 '22 03:09

fmw42


Use -region http://www.imagemagick.org/Usage/masking/#region_warping

convert a.png -region 150x150+599+261 -implode 1.5 +region b.png
like image 23
cancerbero Avatar answered Sep 23 '22 03:09

cancerbero