How to draw two strings over image with different 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
ddinchev
Posts: 2
Joined: 2011-08-28T08:17:46-07:00
Authentication code: 8675308

How to draw two strings over image with different size?

Post by ddinchev »

I want to draw a rectangle with two strings in it. I want the first string to be 15pt size (its a number), second to be 10pt size (the label). It's easy to draw single string with one size to the rectangle, I do it like this:

Code: Select all

$image = new Imagick('someimage.png');
$draw = new ImagickDraw;
$draw->setGravity(Imagick::GRAVITY_CENTER);
$draw->setfont(__DIR__ . DS . 'TREBUCBD.TTF');
$draw->setfontsize(15);
$draw->annotation(0, 0, '50 points');
$image->drawImage($draw);
I tried to do a $draw->push() to push the current settings to the stack then set the font size and annotation again but then the two strings overlap. I've been trying to do this for hours. Any help is very appreciated!

The above implementation is in PHP but probably I will manage to do it even by example that shows it with command line ImageMagick usage.
ddinchev
Posts: 2
Joined: 2011-08-28T08:17:46-07:00
Authentication code: 8675308

Re: How to draw two strings over image with different size?

Post by ddinchev »

Anyone? :(

I have started a bounty on stack overflow for this:
http://stackoverflow.com/questions/7221 ... over-image
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to draw two strings over image with different size?

Post by anthony »

create two separate images (labels:) for the two strings, append them vertically, then overlay them in the center off your image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply