Creating a label with text and rounded corners

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
troyd1
Posts: 73
Joined: 2007-07-29T17:13:19-07:00

Creating a label with text and rounded corners

Post by troyd1 »

I have 6.6.9-7. q16 dynamic - window 2003 server
I want to put text on an existing image with a white background. I used label, but that creates a box. I would like rounded corners. I could use the draw roundrectangle and then put the text inside, but I want it to have it size itself to fit the text as label does when you give it a height only. After I get that to work, I would also like to be able to have the white box wash into the graphic instead of just being like an overlay. Any ideas?

Thanks in advance for any help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating a label with text and rounded corners

Post by fmw42 »

create your text using label: on a white background. then get the dimensions of the image. then create a new image slightly larger with rounded corners (enough larger to accommodate the rounding). then composite your text image in the center of the round rectangle. then composite that over your background image.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Creating a label with text and rounded corners

Post by Bonzo »

Check out Anthony's example for rounded corners here:
http://www.imagemagick.org/Usage/thumbnails/#rounded

The section above it shows how to blur the edges and you can probably combine the two.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Creating a label with text and rounded corners

Post by anthony »

Bonzo wrote:Check out Anthony's example for rounded corners here:
http://www.imagemagick.org/Usage/thumbnails/#rounded
There are quite a number of methods for doing rounded corners listed in that section, each with some advantages and disadvantages. Some can be extended to even fancier corner and edge handling.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
troyd1
Posts: 73
Joined: 2007-07-29T17:13:19-07:00

Re: Creating a label with text and rounded corners

Post by troyd1 »

Thanks, Great stuff!
Post Reply