I need to pixelate parts of an image using an mask image in tif format.
In ImageMagick there are multiple options to do it, for example:
convert -quality 100 source.tif \( -clone 0 -resize 16% -scale 3840x2160! \) \( unsharp_mask.tif \) -composite result.tif
The source image and the unsharp_mask image have the same size: 3840 x 2160
The unsharp_mask image is filled black except the areas which need to pixelated, they are white, in the source image.
How can I do it with GraphicsMagick?
Is there a simple way to achieve the same result?
Updated Answer
Well... with some time spent "dinking around", err, I mean assiduously studying the options, I come up with this which is both faster and also obviates the need for any intermediate files:
cat - <<EOF | gm batch -prompt off
convert source.tif -resize 8x -scale 400x MPR:pixellated
convert -size 400x400 xc:white -fill black -draw "circle 200,200 200,400" MPR:mask
composite source.tif MPR:pixellated MPR:mask result.tif
EOF
It produces the same result as below. If anyone is interested, MPR means "Memory Program Register" and it is basically a chunk of RAM with a name.
Original Answer
There may be a simpler method that you could work out by dinking around for ages, but this seems to do what I think you want.
This is my source image source.tif
and it is 400x400px:
I pixellate it like this:
gm convert source.tif -resize 8x -scale 400x pixellated.tif
Then I make a mask like this - I have artificially added a red outline so you can see the extent on StackOverflow's white background:
gm convert -size 400x400 xc:white -fill black -draw "circle 200,200 200,400" mask.tif
And do the final composite like this:
gm composite source.tif pixellated.tif mask.tif result.tif
By the way, see here for some thoughts on GraphicsMagick vs ImageMagick.