"Hello World" with ImageMagick

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
ReeDees

"Hello World" with ImageMagick

Post by ReeDees »

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:

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 $@;
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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: "Hello World" with ImageMagick

Post by magick »

> $image->ReadImage('xc:white') || die $!;

For proper exception handling, see http://www.imagemagick.org/script/perl- ... exceptions.
ReeDees

Re: "Hello World" with ImageMagick

Post by ReeDees »

Thanks! Got it working now!
Post Reply