| 1 |
#!perl -w |
| 2 |
use Imager; |
| 3 |
use Test::More tests => 22; |
| 4 |
use Imager::Test qw(is_image); |
| 5 |
|
| 6 |
{ |
| 7 |
# GIF files are limited to 0xFFFF x 0xFFFF pixels |
| 8 |
{ |
| 9 |
my $im = Imager->new(xsize => 0x10000, ysize => 1); |
| 10 |
my $data = ''; |
| 11 |
ok(!$im->write(data => \$data, type => "gif"), |
| 12 |
"fail to write too wide an image"); |
| 13 |
is($im->errstr, "image too large for GIF", |
| 14 |
"check error message"); |
| 15 |
} |
| 16 |
SKIP: |
| 17 |
{ |
| 18 |
my $im = Imager->new(xsize => 0xFFFF, ysize => 1); |
| 19 |
$im->box(fill => { hatch => "check4x4" }); |
| 20 |
my $data = ''; |
| 21 |
ok($im->write(data => \$data, type => "gif"), |
| 22 |
"write image at width limit"); |
| 23 |
my $im2 = Imager->new(data => $data, ftype => "gif"); |
| 24 |
ok($im2, "read it ok") |
| 25 |
or skip("cannot load the wide image", 1); |
| 26 |
is_image($im, $im2, "check we read what we wrote"); |
| 27 |
is($im->getwidth, 0xffff, "check width"); |
| 28 |
is($im->getheight, 1, "check height"); |
| 29 |
} |
| 30 |
{ |
| 31 |
my $im = Imager->new(xsize => 1, ysize => 0x10000); |
| 32 |
my $data = ''; |
| 33 |
ok(!$im->write(data => \$data, type => "gif"), |
| 34 |
"fail to write too tall an image"); |
| 35 |
is($im->errstr, "image too large for GIF", |
| 36 |
"check error message"); |
| 37 |
} |
| 38 |
SKIP: |
| 39 |
{ |
| 40 |
my $im = Imager->new(xsize => 1, ysize => 0xFFFF); |
| 41 |
$im->box(fill => { hatch => "check2x2" }); |
| 42 |
my $data = ''; |
| 43 |
ok($im->write(data => \$data, type => "gif"), |
| 44 |
"write image at width limit"); |
| 45 |
my $im2 = Imager->new(data => $data, ftype => "gif"); |
| 46 |
ok($im2, "read it ok") |
| 47 |
or skip("cannot load the wide image", 1); |
| 48 |
is_image($im, $im2, "check we read what we wrote"); |
| 49 |
is($im->getwidth, 1, "check width"); |
| 50 |
is($im->getheight, 0xffff, "check height"); |
| 51 |
} |
| 52 |
} |
| 53 |
{ |
| 54 |
my $im = Imager->new(xsize => 1, ysize => 1); |
| 55 |
$im->settag(name => "gif_screen_width", value => 65536); |
| 56 |
my $data = ''; |
| 57 |
ok(!$im->write(data => \$data, type => "gif"), |
| 58 |
"save a with a large explicit screen width should fail"); |
| 59 |
is($im->errstr, "screen size too large for GIF", |
| 60 |
"check error message"); |
| 61 |
} |
| 62 |
{ |
| 63 |
my $im = Imager->new(xsize => 0x8000, ysize => 1); |
| 64 |
$im->settag(name => "gif_left", value => 32768); |
| 65 |
my $data = ''; |
| 66 |
ok(!$im->write(data => \$data, type => "gif"), |
| 67 |
"save a with a large implicit screen width should fail"); |
| 68 |
is($im->errstr, "screen size too large for GIF", |
| 69 |
"check error message"); |
| 70 |
} |
| 71 |
{ |
| 72 |
my $im = Imager->new(xsize => 1, ysize => 1); |
| 73 |
$im->settag(name => "gif_screen_height", value => 65536); |
| 74 |
my $data = ''; |
| 75 |
ok(!$im->write(data => \$data, type => "gif"), |
| 76 |
"save a with a large explicit screen height should fail"); |
| 77 |
is($im->errstr, "screen size too large for GIF", |
| 78 |
"check error message"); |
| 79 |
} |
| 80 |
{ |
| 81 |
my $im = Imager->new(xsize => 1, ysize => 0x8000); |
| 82 |
$im->settag(name => "gif_top", value => 32768); |
| 83 |
my $data = ''; |
| 84 |
ok(!$im->write(data => \$data, type => "gif"), |
| 85 |
"save a with a large implicit screen height should fail"); |
| 86 |
is($im->errstr, "screen size too large for GIF", |
| 87 |
"check error message"); |
| 88 |
} |