Want image to be size of rounded-rectangle: without -size

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
hknight
Posts: 32
Joined: 2007-08-02T10:16:15-07:00

Want image to be size of rounded-rectangle: without -size

Post by hknight »

Hello,

I would like to create an image that is EXACTLY the size of my rounded-rectangle.

However this does NOT work:

Code: Select all

      convert xc:skyblue -fill white -stroke black \
      -draw "roundrectangle 20,10 80,50 20,15"  draw_rrect.gif
And this does NOT work either:

Code: Select all

      convert xc:skyblue -fill white -stroke black \
      -draw ""@rounded_corner.mvg" draw_rrect.gif
Those both give me an image that is ONLY 1px by 1 px.

I can NOT use the size attribute like this

Code: Select all

      convert -size 100x60 xc:skyblue -fill white -stroke black \
      -draw "roundrectangle 20,10 80,50 20,15"  draw_rrect.gif
because the size is created dynamically and placed into a mvg file.

Any ideas?
Thanks!

Thanks!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Want image to be size of rounded-rectangle: without -size

Post by anthony »

If you have the image size in the MVG file, why are you creating a one pixel image using xc: ?

Without a -size option xc: creates a single pixel image of the color specified.

I suggest you study IM Examples MVG file handling...
http://www.imagemagick.org/Usage/draw/#mvg_file
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
hknight
Posts: 32
Joined: 2007-08-02T10:16:15-07:00

Re: Want image to be size of rounded-rectangle: without -size

Post by hknight »

Thanks, Anthony.

Your direction enabled me create this, which works perfectly. The peice of the puzzle that I was missing was "viewbox"

Code: Select all

convert -background transparent -fill transparent \
           -font 'tahomabd.ttf' -pointsize 14 label:'Hello World \
           -format 'viewbox 0 0 %[fx:w] %[fx:h]  \
 fill white roundRectangle 1,1 %[fx:w-2] %[fx:h-2] \
 %[fx:int((w+h)/33)],%[fx:int((w+h)/33)]' \
            info: > rounded_corner.mvg

convert -background black +antialias rounded_corner.mvg mask.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Want image to be size of rounded-rectangle: without -size

Post by anthony »

Your welcome.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply