"Hello World" with ImageMagick
Posted: 2008-08-14T15:12:33-07:00
Hi all,
I've read through much of perlmagick documentation and am quite impressed; I can't wait to use it. However, i'm having trouble duplicating typical "convert" functionality. For example, for a typical "convert -size 100x100 xc:white foobar.png" I wrote some simple perl:
I see an error, which i'm sure is something *incredibly* simple that I overlooked, "No such file or directory at ./image.pl line 11." which is my ReadImage line. What simple thing am I overlooking?
I've read through much of perlmagick documentation and am quite impressed; I can't wait to use it. However, i'm having trouble duplicating typical "convert" functionality. For example, for a typical "convert -size 100x100 xc:white foobar.png" I wrote some simple perl:
Code: Select all
#!/usr/bin/perl
use strict; use warnings;
use Image::Magick;
my $filename = "foo.png";
eval
{
my $image = Image::Magick->new(size => '100x100');
$image->ReadImage('xc:white') || die $!;
$image->Write(filename => $filename) || die $!;
open(IMAGE, ">$filename");
$image->Write(file=>\*IMAGE, filename=>$filename) || die $!;
close(IMAGE);
};
print $@ if $@;