4 use Test::More tests => 12;
9 # JPEG files are limited to 0xFFFF x 0xFFFF pixels
10 # but libjpeg sets the limit lower to avoid overflows
12 my $im = Imager->new(xsize => 1+$max_dim, ysize => 1);
14 ok(!$im->write(data => \$data, type => "jpeg"),
15 "fail to write too wide an image");
16 is($im->errstr, "image too large for JPEG",
17 "check error message");
21 my $im = Imager->new(xsize => $max_dim, ysize => 1);
22 $im->box(fill => { hatch => "check4x4" });
24 ok($im->write(data => \$data, type => "jpeg"),
25 "write image at width limit")
26 or print "# ", $im->errstr, "\n";
27 my $im2 = Imager->new(data => $data, ftype => "jpeg");
28 ok($im2, "read it ok")
29 or skip("cannot load the wide image", 1);
30 is($im->getwidth, $max_dim, "check width");
31 is($im->getheight, 1, "check height");
34 my $im = Imager->new(xsize => 1, ysize => 1+$max_dim);
36 ok(!$im->write(data => \$data, type => "jpeg"),
37 "fail to write too tall an image");
38 is($im->errstr, "image too large for JPEG",
39 "check error message");
43 my $im = Imager->new(xsize => 1, ysize => $max_dim);
44 $im->box(fill => { hatch => "check2x2" });
46 ok($im->write(data => \$data, type => "jpeg"),
47 "write image at width limit");
48 my $im2 = Imager->new(data => $data, ftype => "jpeg");
49 ok($im2, "read it ok")
50 or skip("cannot load the wide image", 1);
51 is($im->getwidth, 1, "check width");
52 is($im->getheight, $max_dim, "check height");