I get a new image, just large enough to contain the text. I can't seem to replicate that using Image::Magick in Perl. My latest attempt is:convert -background lightgrey -fill black -font Arial label:test test.png
Code: Select all
#!/usr/bin/perl
use strict;
use Image::Magick;
my $dst_file_name = "test.png";
my $res;
my $im = Image::Magick->new;
$res = $im->Set(
background => "lightgrey",
fill => "black",
font => "arial.ttf",
);
die $res if $res;
$im->Label("test");
die $res if $res;
$res = $im->Write($dst_file_name);
die $res if $res;
I can provide it an existing image as canvas, but that defeats my ability to create a minimally sized image (or, for that matter, to determine the maximum height and width of the text for use elsewhere, which is my ultimage goal).Exception 410: no images defined `Image::Magick' at test.pl