-d "testout" or mkdir "testout";
-init_log("testout/t020masked.log", 1);
+Imager->open_log(log => "testout/t020masked.log");
my $base_rgb = Imager::ImgRaw::new(100, 100, 3);
# put something in there
2, "write over right side");
}
}
+
+Imager->close_log();
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t020masked.log";
+}
-d "testout" or mkdir "testout";
-init_log("testout/t021sixteen.log", 1);
+Imager->open_log(log => "testout/t021sixteen.log");
use Imager::Color::Float;
use Imager::Test qw(test_image is_image image_bounds_checks test_colorf_gpix
or print "# ", $im->errstr, "\n";
is_deeply(\@wr_samples, \@samples, "check it matches");
}
+
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t021sixteen.log";
+}
-d "testout" or mkdir "testout";
-init_log("testout/t022double.log", 1);
+Imager->open_log(log => "testout/t022double.log");
use Imager::Test qw(image_bounds_checks test_colorf_gpix test_colorf_glin mask_tests);
ok(!$im->to_rgb_double, "convert empty image to double");
is($im->errstr, "empty input image", "check message");
}
+
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t022double.log";
+}
use Imager::Test qw(image_bounds_checks test_image is_color3);
+Imager->open_log(log => "testout/t023palette.log");
+
sub isbin($$$);
my $img = Imager->new(xsize=>50, ysize=>50, type=>'paletted');
is_color3($colors[8], 0, 0x33, 0x66, "9th should be 003366");
}
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t023palette.log"
+}
+
sub iscolor {
my ($c1, $c2, $msg) = @_;
-d "testout" or mkdir "testout";
-init_log("testout/t05error.log", 1);
+Imager->open_log(log => "testout/t05error.log");
# try to read an invalid pnm file
open FH, "< testimg/junk.ppm"
}
}
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t05error.log";
+}
-d "testout" or mkdir "testout";
-init_log("testout/t07iolayer.log", 1);
+Imager->open_log(log => "testout/t07iolayer.log");
undef($/);
# start by testing io buffer
is($io->close, 0, "close");
}
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t07.ppm", "testout/t07iolayer.log";
+}
+
sub eof_read {
my ($max_len) = @_;
-d "testout" or mkdir "testout";
-Imager::init_log("testout/t1000files.log", 1);
+Imager->open_log(log => "testout/t1000files.log");
SKIP:
{
00 6A 70 32 63 FF 4F FF 51 00 2F 00 00 00 00 01
JPEG2K
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t1000files.log";
+}
+
sub probe_ok {
my ($packed, $exp_type, $name) = @_;
-d "testout" or mkdir "testout";
-init_log("testout/t101jpeg.log",1);
+Imager->open_log(log => "testout/t101jpeg.log");
$Imager::formats{"jpeg"}
and plan skip_all => "have jpeg support - this tests the lack of it";
cmp_ok($im->errstr, '=~', qr/format 'jpeg' not supported/, "check no jpeg message");
ok(!grep($_ eq 'jpeg', Imager->read_types), "check jpeg not in read types");
ok(!grep($_ eq 'jpeg', Imager->write_types), "check jpeg not in write types");
+
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t101jpeg.log";
+}
-d "testout" or mkdir "testout";
-init_log("testout/t103raw.log",1);
+Imager->open_log(log => "testout/t103raw.log");
$| = 1;
"check last channel zeroed");
}
-unlink(qw(testout/t103_base.raw testout/t103_3to4.raw
- testout/t103_line_int.raw testout/t103_img_int.raw))
- unless $ENV{IMAGER_KEEP_FILES};
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t103raw.log";
+ unlink(qw(testout/t103_base.raw testout/t103_3to4.raw
+ testout/t103_line_int.raw testout/t103_img_int.raw))
+}
sub read_test {
my ($in, $xsize, $ysize, $data, $store, $intrl, $base) = @_;
-d "testout" or mkdir "testout";
-init_log("testout/t104ppm.log",1);
+Imager->open_log(log => "testout/t104ppm.log");
my $green = i_color_new(0,255,0,255);
my $blue = i_color_new(0,0,255,255);
my $red = i_color_new(255,0,0,255);
+my @files;
+
my $img = test_image_raw();
my $fh = openimage(">testout/t104.ppm");
+push @files, "t104.ppm";
my $IO = Imager::io_new_fd(fileno($fh));
ok(i_writeppm_wiol($img, $IO), "write pnm low")
or die "Cannot write testout/t104.ppm\n";
i_box_filled($gimg, 40, 40, 110, 110, $dgray);
i_arc($gimg, 75, 75, 30, 0, 361, $white);
+push @files, "t104_gray.pgm";
open FH, "> testout/t104_gray.pgm" or die "Cannot create testout/t104_gray.pgm: $!\n";
binmode FH;
$IO = Imager::io_new_fd(fileno(FH));
$im->box(filled => 1, xmin => 8, color => '#FFE0C0');
$im->box(filled => 1, color => NC(0, 192, 192, 128),
ymin => 8, xmax => 7);
+ push @files, "t104_alpha.ppm";
ok($im->write(file=>"testout/t104_alpha.ppm", type=>'pnm'),
"should succeed writing 4 channel image");
my $imread = Imager->new;
$im->box(filled => 1, xmin => 8, color => '#FFE0C0');
$im->box(filled => 1, color => NC(0, 192, 192, 128),
ymin => 8, xmax => 7);
+ push @files, "t104_alp16.ppm";
ok($im->write(file=>"testout/t104_alp16.ppm", type=>'pnm',
pnm_write_wide_data => 1),
"should succeed writing 4 channel image");
$im->box(filled => 1, xmax => 4, color => '#000000');
$im->box(filled => 1, xmin => 5, color => '#FFFFFF');
is($im->type, 'paletted', 'mono still paletted');
+ push @files, "t104_mono.pbm";
ok($im->write(file => 'testout/t104_mono.pbm', type => 'pnm'),
"save as pbm");
$im->box(filled => 1, xmax => 4, color => '#000000');
$im->box(filled => 1, xmin => 5, color => '#FFFFFF');
is($im->type, 'paletted', 'mono still paletted');
+ push @files, "t104_mono2.pbm";
ok($im->write(file => 'testout/t104_mono2.pbm', type => 'pnm'),
"save as pbm");
$data = '';
ok($im->write(data => \$data, type => 'pnm'),
"write 16-bit image as 16-bit/sample ppm");
+ push @files, "t104_16.ppm";
$im->write(file=>'testout/t104_16.ppm');
my $im16 = Imager->new;
ok($im16->read(data => $data), "read it back");
is($im16->tags(name => 'pnm_maxval'), 65535, "check maxval");
+ push @files, "t104_16b.ppm";
$im16->write(file=>'testout/t104_16b.ppm');
is_image($im, $im16, "check image matches");
}
}
}
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink "testout/t104ppm.log";
+ unlink map "testout/$_", @files;
+}
+
sub openimage {
my $fname = shift;
local(*FH);
-d "testout" or mkdir "testout";
-init_log("testout/t107bmp.log",1);
+Imager->open_log(log => "testout/t107bmp.log");
+my @files;
my $debug_writes = 0;
my $base_diff = 0;
Imager::i_tags_add($img, 'i_xres', 0, '300', 0);
Imager::i_tags_add($img, 'i_yres', 0, undef, 300);
write_test($img, "testout/t107_24bit.bmp");
+push @files, "t107_24bit.bmp";
# 'webmap' is noticably faster than the default
my $im8 = Imager::i_img_to_pal($img, { make_colors=>'webmap',
translate=>'errdiff'});
write_test($im8, "testout/t107_8bit.bmp");
+push @files, "t107_8bit.bmp";
# use a fixed palette so we get reproducible results for the compressed
# version
my @pal16 = map { NC($_) }
2ead1b 0000f8 004b01 fd0000 0e1695 000002);
my $im4 = Imager::i_img_to_pal($img, { colors=>\@pal16, make_colors=>'none' });
write_test($im4, "testout/t107_4bit.bmp");
+push @files, "t107_4bit.bmp";
my $im1 = Imager::i_img_to_pal($img, { colors=>[ NC(0, 0, 0), NC(176, 160, 144) ],
make_colors=>'none', translate=>'errdiff' });
write_test($im1, "testout/t107_1bit.bmp");
+push @files, "t107_1bit.bmp";
my $bi_rgb = 0;
my $bi_rle8 = 1;
my $bi_rle4 = 2;
ok($imoo->write(file=>'testout/t107_oo.bmp'), "write via OO")
or print "# ",$imoo->errstr,"\n";
+push @files, "t107_oo.bmp";
# various invalid format tests
# we have so many different test images to try to detect all the possible
ymin => 8, xmax => 7);
ok($im->write(file=>"testout/t107_alpha.bmp", type=>'bmp'),
"should succeed writing 4 channel image");
+ push @files, "t107_alpha.bmp";
my $imread = Imager->new;
ok($imread->read(file => 'testout/t107_alpha.bmp'), "read it back");
is_color3($imread->getpixel('x' => 0, 'y' => 0), 0, 0, 0,
is($size, 67800, "check data size");
}
+Imager->close_log;
+
+unless ($ENV{IMAGER_KEEP_FILES}) {
+ unlink map "testout/$_", @files;
+ unlink "testout/t107bmp.log";
+}
+
sub write_test {
my ($im, $filename) = @_;
local *FH;