]>
Commit | Line | Data |
---|---|---|
8d14daab TC |
1 | #!perl -w |
2 | use strict; | |
3 | use Imager; | |
4 | use Test::More tests => 12; | |
5 | ||
6 | my $max_dim = 65500; | |
7 | ||
8 | { | |
9 | # JPEG files are limited to 0xFFFF x 0xFFFF pixels | |
10 | # but libjpeg sets the limit lower to avoid overflows | |
11 | { | |
12 | my $im = Imager->new(xsize => 1+$max_dim, ysize => 1); | |
13 | my $data = ''; | |
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"); | |
18 | } | |
19 | SKIP: | |
20 | { | |
21 | my $im = Imager->new(xsize => $max_dim, ysize => 1); | |
22 | $im->box(fill => { hatch => "check4x4" }); | |
23 | my $data = ''; | |
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"); | |
32 | } | |
33 | { | |
34 | my $im = Imager->new(xsize => 1, ysize => 1+$max_dim); | |
35 | my $data = ''; | |
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"); | |
40 | } | |
41 | SKIP: | |
42 | { | |
43 | my $im = Imager->new(xsize => 1, ysize => $max_dim); | |
44 | $im->box(fill => { hatch => "check2x2" }); | |
45 | my $data = ''; | |
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"); | |
53 | } | |
54 | } |