use
5.006;
BEGIN {
our
$VERSION
=
"1.001"
;
XSLoader::load(
'Imager::File::GIF'
,
$VERSION
);
}
Imager->register_reader
(
type
=>
'gif'
,
single
=>
sub
{
my
(
$im
,
$io
,
%hsh
) =
@_
;
if
(
$hsh
{gif_consolidate}) {
if
(
$hsh
{colors}) {
my
$colors
;
(
$im
->{IMG},
$colors
) =i_readgif_wiol(
$io
);
if
(
$colors
) {
${
$hsh
{colors} } = [
map
{ NC(
@$_
) }
@$colors
];
}
}
else
{
$im
->{IMG} =i_readgif_wiol(
$io
);
}
}
else
{
my
$page
=
$hsh
{page};
defined
$page
or
$page
= 0;
$im
->{IMG} = i_readgif_single_wiol(
$io
,
$page
);
unless
(
$im
->{IMG}) {
$im
->_set_error(Imager->_error_as_msg);
return
;
}
if
(
$hsh
{colors}) {
${
$hsh
{colors} } = [
$im
->getcolors ];
}
return
$im
;
}
},
multiple
=>
sub
{
my
(
$io
,
%hsh
) =
@_
;
my
@imgs
= i_readgif_multi_wiol(
$io
);
unless
(
@imgs
) {
Imager->_set_error(Imager->_error_as_msg);
return
;
}
return
map
bless
({
IMG
=>
$_
,
ERRSTR
=>
undef
},
"Imager"
),
@imgs
;
},
);
Imager->register_writer
(
type
=>
'gif'
,
single
=>
sub
{
my
(
$im
,
$io
,
%hsh
) =
@_
;
$im
->_set_opts(\
%hsh
,
"i_"
,
$im
);
$im
->_set_opts(\
%hsh
,
"gif_"
,
$im
);
unless
(i_writegif_wiol(
$io
, \
%hsh
,
$im
->{IMG})) {
$im
->_set_error(Imager->_error_as_msg);
return
;
}
return
$im
;
},
multiple
=>
sub
{
my
(
$class
,
$io
,
$opts
,
@ims
) =
@_
;
Imager->_set_opts(
$opts
,
"gif_"
,
@ims
);
my
@work
=
map
$_
->{IMG},
@ims
;
unless
(i_writegif_wiol(
$io
,
$opts
,
@work
)) {
Imager->_set_error(Imager->_error_as_msg);
return
;
}
return
1;
},
);