What are % , fx and \n ?
fx is the imagemagick calculation command
%[fx: ...] does the computation according to the formula you provide (in this case the minimum of the image width and height.
\n puts a line break in the returned result
Please see
http://www.imagemagick.org/script/fx.php
http://www.imagemagick.org/Usage/transform/#fx_escapes
What is xc ?
xc:somecolor tells IM to create a new image of some color. It is equivalent to canvas. It is needed as a placeholder for doing calculations. If no size is specified and no color is specified then it creates a one pixel transparent image. See links above and
http://www.imagemagick.org/script/formats.php#pseudo
What are "circle $dim2,$dim2 0,$dim2"
-draw "circle xcenter,ycenter xcenter,ycenter+radius" is the command to draw a circle. See
http://www.imagemagick.org/Usage/draw/#primitives
http://www.imagemagick.org/Usage/draw/#circles
http://www.imagemagick.org/script/magic ... aphics.php
Why put the circle image into the alpha channel
I use the circle twice. The first time I put it into the alpha channel of the image so that where it is white , you see the image and where it is black, you get fully transparent pixels. That is how to make a circle of an image. It is really a square, but only the interior of the circle shows through.
The second time, I have taken the circle and generate an edge image to be a ring. I make the ring red and the rest as transparent. I then overlay it onto the previous resulting image.
Imagemagick can have a bit of a learning curve for novices, so please take some time to review the following:
viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
One way to learn about such long commands is to put +write tmpX.png after each operator and see what the results look like. Then you can correlate the results to the commands.
So try this:
dim=`convert image_02.jpg -format "%[fx:min(w,h)]\n" info:`
echo "dim=$dim"
dim2=`convert xc: -format "%[fx:$dim/2]" info:`
echo "dim2=$dim2"
Code: Select all
convert scenery-008.jpg chinese_08_transp.png \
-gravity center -define compose:args=80 -compose blend -composite +write tmp1.png \
\( image_02.jpg -gravity center -crop ${dim}x${dim}+0+0 +repage +write tmp2.png -write mpr:img +delete \) \
\( mpr:img -fill black -colorize 100 +write tmp3.png \
-fill white -draw "circle $dim2,$dim2 0,$dim2" +write tmp4.png -write mpr:circle \
mpr:img +swap -alpha off -compose copy_opacity -composite +write tmp5.png \) \
-gravity northeast -compose over -composite +write tmp6.png \
\( mpr:circle -bordercolor black -border 3 -morphology edgein disk:5 -shave 3x3 +write tmp7.png \
-background red -alpha shape +write tmp8.png \) \
-gravity northeast -compose over -composite \
result.png