
ImageMagick: How to Pixelate Part of an Image
Updated
Learn how to pixelate just one part of an image using ImageMagick
Before we start, make sure you have ImageMagick installed on your computer and your photo ready in a folder. If you don't have it yet, run this command:
brew install imagemagick
First, open your terminal and navigate to the folder that has your photo. Pixelating one area takes two steps. First, cut that area out and turn it into big blocks by running this command:
magick input.jpg -crop 400x240+430+800 +repage -scale 5% -scale 2000% patch.png
The -crop option takes the width and height, then how far from the left and from the top, so 400x240+430+800 is a box 400 pixels wide and 240 tall. Then -scale 5% shrinks it and -scale 2000% blows it back up, which makes the blocks. Just remember to replace input.jpg with your actual filename.
Now put the patch back on the photo:
magick input.jpg patch.png -geometry +430+800 -composite output.jpg
The -geometry +430+800 option says where the patch goes, and -composite pastes it on. To make sure everything worked, run open output.jpg and check that only that area is pixelated.
One more tip: for smaller blocks, use -scale 10% and -scale 1000% instead. Just keep the two percentages as opposites, so the patch stays the same size.
