3 $^W=1; # warnings during command-line tests
4 $|=1; # give us some progress in the test harness
5 init_log("testout/t106tiff.log",1);
7 $green=i_color_new(0,255,0,255);
8 $blue=i_color_new(0,0,255,255);
9 $red=i_color_new(255,0,0,255);
11 $img=Imager::ImgRaw::new(150,150,3);
13 i_box_filled($img,70,25,130,125,$green);
14 i_box_filled($img,20,25,80,125,$blue);
15 i_arc($img,75,75,30,0,361,$red);
16 i_conv($img,[0.1, 0.2, 0.4, 0.2, 0.1]);
18 my $timg = Imager::ImgRaw::new(20, 20, 4);
19 my $trans = i_color_new(255, 0, 0, 127);
20 i_box_filled($timg, 0, 0, 20, 20, $green);
21 i_box_filled($timg, 2, 2, 18, 18, $trans);
23 if (!i_has_format("tiff")) {
25 print "ok $_ # skip no tiff support\n";
28 open(FH,">testout/t106.tiff") || die "cannot open testout/t10.tiff for writing\n";
30 my $IO = Imager::io_new_fd(fileno(FH));
31 i_writetiff_wiol($img, $IO);
36 open(FH,"testout/t106.tiff") or die "cannot open testout/t106.tiff\n";
38 $IO = Imager::io_new_fd(fileno(FH));
39 $cmpimg = i_readtiff_wiol($IO, -1);
43 print "# tiff average mean square pixel difference: ",sqrt(i_img_diff($img,$cmpimg))/150*150,"\n";
46 i_img_diff($img, $cmpimg) and print "not ";
49 $IO = Imager::io_new_bufchain();
51 Imager::i_writetiff_wiol($img, $IO) or die "Cannot write to bufferchain\n";
52 my $tiffdata = Imager::io_slurp($IO);
54 open(FH,"testout/t106.tiff");
60 if ($odata eq $tiffdata) {
66 # test Micksa's tiff writer
68 my $faximg = Imager::ImgRaw::new(1728, 2000, 1);
69 my $black = i_color_new(0,0,0,255);
70 my $white = i_color_new(255,255,255,255);
71 # vaguely test-patterny
72 i_box_filled($faximg, 0, 0, 1728, 2000, $white);
73 i_box_filled($faximg, 100,100,1628, 200, $black);
76 while ($width+$pos < 1628) {
77 i_box_filled($faximg, $pos, 300, $pos+$width-1, 400, $black);
81 open FH, "> testout/t106tiff_fax.tiff"
82 or die "Cannot create testout/t106tiff_fax.tiff: $!";
84 $IO = Imager::io_new_fd(fileno(FH));
85 i_writetiff_wiol_faxable($faximg, $IO, 1)
90 # test the OO interface
91 my $ooim = Imager->new;
92 $ooim->read(file=>'testout/t106.tiff')
95 $ooim->write(file=>'testout/t106_oo.tiff')
99 # OO with the fax image
100 my $oofim = Imager->new;
101 $oofim->read(file=>'testout/t106tiff_fax.tiff')
104 $oofim->write(file=>'testout/t106_oo_fax.tiff', class=>'fax')
108 # the following should fail since there's no type and no filename
110 $ooim->write(data=>\$oodata)
115 $ooim->write(data=>\$oodata, type=>'tiff')
118 $oodata eq $tiffdata or print "not ";
121 # make sure we can write non-fine mode
122 $oofim->write(file=>'testout/t106_oo_faxlo.tiff', class=>'fax', fax_fine=>0)