Initial revision
[imager.git] / t / t58trans2.t
1 BEGIN { $| = 1; print "1..6\n"; }
2 END {print "not ok 1\n" unless $loaded;}
3 use Imager;
4
5 $loaded = 1;
6 print "ok 1\n";
7
8 #$Imager::DEBUG=1;
9
10 Imager::init('log'=>'testout/t56trans2.log');
11
12 my $im1 = Imager->new();
13 $im1->open(file=>'testimg/penguin-base.ppm', type=>'pnm')
14          || die "Cannot read image";
15 my $im2 = Imager->new();
16 $im2->open(file=>'testimg/scale.ppm',type=>'pnm')
17         || die "Cannot read testimg/scale.ppm";
18
19 # error handling
20 my $opts = { rpnexpr=>'x x 10 / sin 10 * y + get1' };
21 my $im3 = Imager::transform2($opts);
22 print $im3 ? "not ok 2\n" : "ok 2\n";
23 print defined($Imager::ERRSTR) ? "ok 3\n" : "not ok 3\n";
24
25 # image synthesis
26 my $im4 = Imager::transform2({
27         width=>300, height=>300,
28         rpnexpr=>'x y cx cy distance !d y cy - x cx - atan2 !a @d 10 / @a + 3.1416 2 * % !a2 @a2 cy * 3.1416 / 1 @a2 sin 1 + 2 / hsv'});
29 print $im4 ? "ok 4\n" : "not ok 4\n";
30
31 if ($im4) {
32   $im4->write(type=>'pnm', file=>'testout/t56a.ppm')
33     || die "Cannot write testout/t56a.ppm";
34 }
35
36 # image distortion
37 my $im5 = Imager::transform2({
38         rpnexpr=>'x x 10 / sin 10 * y + getp1'
39 }, $im1);
40 print $im5 ? "ok 5\n" : "not ok 5\n";
41 if ($im5) {
42   $im5->write(type=>'pnm', file=>'testout/t56b.ppm')
43     || die "Cannot write testout/t56b.ppm";
44 }
45
46 # image combination
47 $opts = {
48 rpnexpr=>'x h / !rat x w2 % y h2 % getp2 !pat x y getp1 @rat * @pat 1 @rat - * +'
49 };
50 my $im6 = Imager::transform2($opts,$im1,$im2);
51 print $im6 ? "ok 6\n" : "not ok 6 # $opts->{error}\n";
52 if ($im6) {
53   $im6->write(type=>'pnm', file=>'testout/t56c.ppm')
54     || die "Cannot write testout/t56c.ppm";
55 }