Page 1 of 1

Creating a rounded corner

Posted: 2006-09-25T16:03:41-07:00
by riegel

I modified the code from ... humbnails/ for creating rounded corners so that it could be used all in one command.

On the site I changed this...

Code: Select all

convert -size 15x15 xc:white -draw 'circle 0,0 0,14' \
            \( xc:none -draw 'circle 0,0 0,12' \) \
            -compose DstOut -composite     rounded_corner.png

    convert thumbnail.gif   -bordercolor black -border 2 -matte \
            \( rounded_corner.png -flip -flop \) -gravity NorthWest -composite \
            \( rounded_corner.png       -flop \) -gravity SouthWest -composite \
            \( rounded_corner.png -flip       \) -gravity NorthEast -composite \
            \( rounded_corner.png             \) -gravity SouthEast -composite \
            +matte  -depth 8  -quality 95  rounded_corners.png

It now looks like this...

Code: Select all

-geometry 200x200
-bordercolor "#9FB08E"
-border 2
\( -size 15x15
   -draw 'circle 0,0 0,14'
   \( xc:none
      'circle 0,0 0,12' \)
   -compose DstOut
   -flip -flop \)
-gravity NorthWest
My problem is since I do not fully understand the code I can't seem to figure out how to change the color of the rounded border. Any ideas on how I can do this.


I would like to make the border and corner green.

Posted: 2006-09-25T23:38:57-07:00
by anthony
before the first -draw add -fill "#9FB08E"
The default fill color is black. The color of the second draw does not matter as it is a mask which only looks at the transparency components of that image.

Also once you have made one corner image, save it into an mpr: in memory image register, and delete the image from the current image sequence. That way you can just copy the image from the mpr: without having re-create it over and over, or use a temporary file on the disk.

Code: Select all

convert -size 15x15 xc:white -fill #9FB08E"  -draw 'circle 0,0 0,14' \
            \( xc:none -draw 'circle 0,0 0,12' \) \
            -compose DstOut -composite  -write mpr:corner +delete \
           IMAGE.PNG  -bordercolor  #9FB08E"-border 2 -matte \
          \( mpr:corner -flip -flop \) -gravity NorthWest -composite \
          .... \
Just repeat the ... part as in my examples to overlay the corner image on each of the four corners.

If you want the corners masked to transparency instead of white (set using the first xc:), you will need two images, one overlay, to color the corner, and another to make the transparent parts, transparent. I believe it ws the next example in IM Examples.

Note the circle radius of 12 and 14, is two pixels different to match up to the 2 pixel border. Adjust as you see fit.