Annotate autosize

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.

Annotate autosize

Postby walzmyn » 2010-07-28T18:55:27+00:00

The IM command line command
Code: Select all
convert -size 300x300 xc:white -fill black -gravity center label:MakeThisWork example.png

will make a white image with the text "MakeThisWork" across it in black. The magick piece here is if you don't give the label a pointsize it will autosize the text to fit inside the image.

Is there away to make this auto-sizing bit work in perlmagick? I've experimented with a whole bunch of options, but not been successful, it seems to really want to have a pointsize given to it.

Thanks in advance.
walzmyn
 
Posts: 4
Joined: 2010-07-28T18:45:21+00:00

Re: Annotate autosize

Postby fmw42 » 2010-07-28T19:17:52+00:00

I don't know PerlMagick, but you can try to give it just a width or height (and no pointsize) and that may then allow it to autosize to fill the width or height.

see command line examples at http://www.imagemagick.org/Usage/text/#label_bestfit
User avatar
fmw42
 
Posts: 4822
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: Annotate autosize

Postby walzmyn » 2010-07-29T15:30:31+00:00

Yeah, that's what the line I used as an example does. I can get a standard IM command to do exactly what I want, I can't get perlmagick to emulate.
I've tried passing it a 'size' argument, making the pointsize 'auto' and the geometry argument. But anything with out a pointsize seems to just give you a default size, not scaled to the containing image.

By the way, after running several tests, I don't know what the geometry argument does either :)
walzmyn
 
Posts: 4
Joined: 2010-07-28T18:45:21+00:00

Re: Annotate autosize

Postby fmw42 » 2010-07-29T15:43:34+00:00

I believe the -geometry argument allows you to offset the text anywhere you want rather than using -gravity to just center or put in corners (or in combination to -gravity so that you can position offsets for example relative to -gravity center or some other -gravity position such as the bottom)

I think you will need a PerlMagick expert to help on the auto issue.

Did you try supplying only one dimension -- either width or height -- rather than both?
User avatar
fmw42
 
Posts: 4822
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: Annotate autosize

Postby walzmyn » 2010-07-29T16:37:02+00:00

Yes I did. I've tried dozens of combinations, no love.
walzmyn
 
Posts: 4
Joined: 2010-07-28T18:45:21+00:00


Return to PerlMagick

Who is online

Users browsing this forum: No registered users and 1 guest