I have a bunch of script that take API data and place a paragraph centered in a box using IM caption in Perl.
The issue is the paragraphs can be anywhere from around 20 characters to around 120 characters.
So typically I use a 36 point font for a 280x250 size box.
I do a character count on the text and if it is over 65 I remove the pointsize so that the text is resized to fit the box.
Code: Select all
my $daily_7_summary_length = length($daily_7_summary);
my $daily_7_summary_image = Image::Magick->new;
$daily_7_summary_image->Set(
background => $summary_background,
fill => $fontcolor1,
gravity => 'center',
font => "$font2",
size => '280x250'
);
if ( $daily_7_summary_length < 68 ) {
$daily_7_summary_image->Set(
pointsize => 36
);
}
$daily_7_summary_image->Read("caption:$daily_7_summary");
I am just looking to see if maybe there is a better way that I haven't seen or figured out yet, that would make the code even cleaner?
Or maybe a future feature request for a maxpointsize option?
Thanks!
John