trying to write a colored number inside a circle

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
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

trying to write a colored number inside a circle

Post by manit »

Hi,
I am using imagemagick on 64bit ubuntu OS

$ convert -version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib

I am trying to write a number inside a circle.
I have tried following
$convert -size 388x374 xc:white sth.png
$convert sth.png -fill none -strokewidth 2 -stroke red -draw 'circle 108,283 108,293' sth-with-circle.png
$ convert sth-with-circle.png -fill none -strokewidth 2 -stroke black -draw 'rectangle 98,273 118,293' sth-with-circle-and-rect.png
$ convert sth-with-circle-and-rect.png \( -size 20x20 -background none label:"12" -trim -gravity center -extent 20x20 \) -gravity northwest -geometry +98+273 -composite sth-with-circle-rectangle-number.png
My problem is that 12 is written in black .
I tried -fill green , -stroke green next to label option .
Thanks.
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Re: trying to write a colored number inside a circle

Post by manit »

I tried

-stroke blue -strokewidth 1 before label then it worked.

This thread is solved.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: trying to write a colored number inside a circle

Post by fmw42 »

No need for 4 commands.

Code: Select all

convert -size 388x374 xc:white \
-fill none -strokewidth 2 -stroke red -draw 'circle 108,283 108,293' \
-fill none -strokewidth 2 -stroke black -draw 'rectangle 98,273 118,293' \
\( -size 20x20 -background none -stroke blue -strokewidth 1 label:"12" -trim +repage -gravity center -extent 20x20 \) \
-gravity northwest -geometry +98+273 -composite sth-with-circle-rectangle-number.png
Post Reply