Hi everyone,
I've been trying to use the library Image::Magick to open an image, write some text in it, and then print it.
However, all I could do is to write some text on a white (or any other color) background. I want to set an image of mine as the background of the picture.
I tried the subroutine ReadImage('MY_PICTURE_PATH') but it didn't work.
Here is the source code I wrote:
Any suggestions or comments will be highly appreciated.
Thanks in advance,
Cheers,
I've been trying to use the library Image::Magick to open an image, write some text in it, and then print it.
However, all I could do is to write some text on a white (or any other color) background. I want to set an image of mine as the background of the picture.
I tried the subroutine ReadImage('MY_PICTURE_PATH') but it didn't work.
Here is the source code I wrote:
Code:
sub print_button{
my $class = shift;
my $text = shift;
my $width = 200;
my $height = 200;
my $size = $width."x".$height;
my $image = Image::Magick->new();
$image->Set(size=>$size);
$image->ReadImage('xc:white');
$image->Set(magick => 'gif');
$image->Annotate(
text => $text,
fill => 'black', #$color,
pointsize => 20,
gravity => 'Center',
font => $char_font,
antialias => 'true'
);
my @blobs = $image->ImageToBlob();
print $blobs[0];
}
Any suggestions or comments will be highly appreciated.
Thanks in advance,
Cheers,