5 Imager::init_log("testout/t61filters.log", 1);
6 # meant for testing the filters themselves
7 my $imbase = Imager->new;
8 $imbase->open(file=>'testout/t104.ppm') or die;
9 my $im_other = Imager->new(xsize=>150, ysize=>150);
10 $im_other->box(xmin=>30, ymin=>60, xmax=>120, ymax=>90, filled=>1);
14 test($imbase, 1, {type=>'autolevels'}, 'testout/t61_autolev.ppm');
16 test($imbase, 3, {type=>'contrast', intensity=>0.5},
17 'testout/t61_contrast.ppm');
19 # this one's kind of cool
20 test($imbase, 5, {type=>'conv', coef=>[ -0.5, 1, -0.5, ], },
21 'testout/t61_conv.ppm');
23 test($imbase, 7, {type=>'gaussian', stddev=>5 },
24 'testout/t61_gaussian.ppm');
26 test($imbase, 9, { type=>'gradgen', dist=>1,
29 colors=> [ NC('#FF0000'), NC('#FFFF00'), NC('#00FFFF') ]},
30 'testout/t61_gradgen.ppm');
32 test($imbase, 11, {type=>'mosaic', size=>8}, 'testout/t61_mosaic.ppm');
34 test($imbase, 13, {type=>'hardinvert'}, 'testout/t61_hardinvert.ppm');
36 test($imbase, 15, {type=>'noise'}, 'testout/t61_noise.ppm');
38 test($imbase, 17, {type=>'radnoise'}, 'testout/t61_radnoise.ppm');
40 test($imbase, 19, {type=>'turbnoise'}, 'testout/t61_turbnoise.ppm');
42 test($imbase, 21, {type=>'bumpmap', bump=>$im_other, lightx=>30, lighty=>30},
43 'testout/t61_bumpmap.ppm');
45 test($imbase, 23, {type=>'bumpmap_complex', bump=>$im_other}, 'testout/t61_bumpmap_complex.ppm');
47 test($imbase, 25, {type=>'postlevels', levels=>3}, 'testout/t61_postlevels.ppm');
49 test($imbase, 27, {type=>'watermark', wmark=>$im_other },
50 'testout/t61_watermark.ppm');
52 test($imbase, 29, {type=>'fountain', xa=>75, ya=>75, xb=>85, yb=>30,
53 repeat=>'triangle', #ftype=>'radial',
54 super_sample=>'circle', ssample_param => 16,
56 'testout/t61_fountain.ppm');
59 my $f1 = Imager::Fountain->new;
60 $f1->add(end=>0.2, c0=>NC(255, 0,0), c1=>NC(255, 255,0));
61 $f1->add(start=>0.2, c0=>NC(255,255,0), c1=>NC(0,0,255,0));
62 test($imbase, 31, { type=>'fountain', xa=>20, ya=>130, xb=>130, yb=>20,
66 'testout/t61_fountain2.ppm');
67 my $f2 = Imager::Fountain->new
68 ->add(end=>0.5, c0=>NC(255,0,0), c1=>NC(255,0,0), color=>'hueup')
69 ->add(start=>0.5, c0=>NC(255,0,0), c1=>NC(255,0,0), color=>'huedown');
72 test($imbase, 33, { type=>'fountain', xa=>20, ya=>130, xb=>130, yb=>20,
74 'testout/t61_fount_hsv.ppm');
75 my $f3 = Imager::Fountain->read(gimp=>'testimg/gimpgrad')
78 test($imbase, 36, { type=>'fountain', xa=>75, ya=>75, xb=>90, yb=>15,
79 segments=>$f3, super_sample=>'grid',
80 ftype=>'radial_square', combine=>'color' },
81 'testout/t61_fount_gimp.ppm');
82 test($imbase, 38, { type=>'unsharpmask', stddev=>2.0 },
83 'testout/t61_unsharp.ppm');
84 test($imbase, 40, {type=>'conv', coef=>[ -1, 3, -1, ], },
85 'testout/t61_conv_sharp.ppm');
87 # Regression test: the checking of the segment type was incorrect
88 # (the comparison was checking the wrong variable against the wrong value)
89 my $f4 = [ [ 0, 0.5, 1, NC(0,0,0), NC(255,255,255), 5, 0 ] ];
90 test($imbase, 42, {type=>'fountain', xa=>75, ya=>75, xb=>90, yb=>15,
91 segments=>$f4, super_sample=>'grid',
92 ftype=>'linear', combine=>'color' },
93 'testout/t61_regress_fount.ppm');
94 my $im2 = $imbase->copy;
95 $im2->box(xmin=>20, ymin=>20, xmax=>40, ymax=>40, color=>'FF0000', filled=>1);
96 $im2->write(file=>'testout/t61_diff_base.ppm');
97 my $im3 = Imager->new(xsize=>150, ysize=>150, channels=>3);
98 $im3->box(xmin=>20, ymin=>20, xmax=>40, ymax=>40, color=>'FF0000', filled=>1);
99 my $diff = $imbase->difference(other=>$im2);
100 print $diff ? "ok 44\n" : "not ok 44\n";
102 print Imager::i_img_diff($im3->{IMG}, $diff->{IMG}) ? "not ok 45\n" : "ok 45\n";
105 print "ok 45 # skip\n";
109 my ($in, $num, $params, $out) = @_;
111 my $copy = $in->copy;
112 if ($copy->filter(%$params)) {
114 if ($copy->write(file=>$out)) {
115 print "ok ",$num+1,"\n";
118 print "not ok ",$num+1," # ",$copy->errstr,"\n";
122 print "not ok $num # ",$copy->errstr,"\n";
123 print "ok ",$num+1," # skipped\n";