measuring string size for Annotate()
Is there a way to figure out if text added via Annotate() got cut off when added to a background of a fixed size? Alternatively is there a way to figure out how much room will be needed for text? I have something like the following but in some cases the string stored in $names is too big and I either need to automatically adjust the font size or at least log a warning at the program output.
Code: Select all
my $text_back = Image::Magick->new(); my $x = $text_back->ReadImage('xc:white'); warn "$x" if "$x"; my $my_h = 150; my $my_w = 600; print "[$my_w x $my_h] ..."; $text_back->Resize(width=>$my_w, height=>$my_h); # code here to read $names out of a file. It may be # a couple of lines long print "Adding label..."; $text_back->Annotate(undercolor=>'white', font=>'LCALLIG.TTF', pointsize=>36, fill=>'black', gravity=>'Center', text=>$names);