]> git.imager.perl.org - imager.git/blob - t/t50basicoo.t
fc43b9e0a4ce868ff5b1028b54253657db23ad1b
[imager.git] / t / t50basicoo.t
1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl test.pl'
3
4 ######################### We start with some black magic to print on failure.
5
6 # Change 1..1 below to 1..last_test_to_print .
7 # (It may become useful if the test is moved to ./t subdirectory.)
8
9 BEGIN { $| = 1; print "1..2\n"; }
10 END {print "not ok 1\n" unless $loaded;}
11 use Imager;
12
13 $loaded = 1;
14
15 print "ok 1\n";
16
17 Imager::init(log=>"testout/t50basicoo.log");
18
19 %hsh=%Imager::formats;
20
21 print "# avaliable formats:\n";
22 for(keys %hsh) { print "# $_\n"; }
23
24 #print Dumper(\%hsh);
25
26 $img = Imager->new();
27
28 @types = qw( jpeg png raw ppm gif tiff );
29
30 @files{@types} = ({ file => "testout/t101.jpg"  },
31                   { file => "testout/t102.png"  },
32                   { file => "testout/t103.raw", xsize=>150, ysize=>150, type=>"raw" },
33                   { file => "testout/t104.ppm"  },
34                   { file => "testout/t105.gif"  },
35                   { file => "testout/t106.tiff" });
36
37 for $type (@types) {
38   next unless $hsh{$type};
39   my %opts = %{$files{$type}};
40   my @a = map { "$_=>${opts{$_}}" } keys %opts;
41   print "#opening Format: $type, options: @a\n";
42   $img->read( %opts ) or die "failed: ",$img->errstr,"\n";
43 }
44
45 $img2=$img->crop(width=>50, height=>50);
46 $img2->write(file=> 'testout/t50.ppm', type=>'pnm');
47
48 undef($img);
49
50 Imager::malloc_state();
51
52 print "ok 2\n";