Hi,
I like to add two "MSWin32"-formats .ico and .cur:
# Package lexicals - invisible to outside world, used only in imgsize
#
# Mapping of patterns to the sizing routines
my %type_map = ( '^GIF8[7,9]a' => \&gifsize,
"^\xFF\xD8" => \&jpegsize,
"^\x89PNG\x0d\x0a\x1a\x0a" => \&pngsize,
"^P[1-7]" => \&ppmsize, # also XVpics
'\#define\s+\S+\s+\d+' => \&xbmsize,
'\/\* XPM \*\/' => \&xpmsize,
'^MM\x00\x2a' => \&tiffsize,
'^II\x2a\x00' => \&tiffsize,
'^BM' => \&bmpsize,
'^8BPS' => \&psdsize,
'^PCD_OPA' => \&pcdsize,
'^FWS' => \&swfsize,
'^CWS' => \&swfmxsize,
"^\x8aMNG\x0d\x0a\x1a\x0a" => \&mngsize,
'^\x00\x00\x01\x00' => \&iconsize,
# 20090520 thw@cpan.org
'^\x00\x00\x02\x00' => \&cursize,
# 20090520 thw@cpan.org
);
# and later....
# Icon (MSWin32) (.ico, .cur)
# 20090520 thw@cpan.org
#
# 20090520 thw@cpan.org
# Icon Header Stores general information about the ICO file.
# 20090520 thw@cpan.org
# Directory[1..n] Stores general information about every image in the
file. # 20090520 thw@cpan.org
#
# Header (size=6)
# 20090520 thw@cpan.org
# Offset# Size Purpose
# 20090520 thw@cpan.org
# 0 2 reserved. should always be 0
# 20090520 thw@cpan.org
# 2 2 type. 1 for icon (.ICO), 2 for cursor (.CUR) file
# 20090520 thw@cpan.org
# 4 2 count; number of images in the file
# 20090520 thw@cpan.org
#
# 20090520 thw@cpan.org
# Directory (size=16)
# 20090520 thw@cpan.org
# Offset# Size Purpose
# 20090520 thw@cpan.org
# 0 1 width, should be 0 if 256 pixels
# 20090520 thw@cpan.org
# 1 1 height, should be 0 if 256 pixels
# 20090520 thw@cpan.org
#
# 20090520 thw@cpan.org
# Thomas Walloschke <thw@cpan.org> 20090520
# 20090520 thw@cpan.org
sub iconsize
# 20090520 thw@cpan.org
{
# 20090520 thw@cpan.org
my $stream = shift;
# 20090520 thw@cpan.org
my ( $x, $y, $id ) = ( undef, undef, "could not determine ICO size"
); # 20090520 thw@cpan.org
my ( $offset, $length ) = ( 6, 2 );
# 20090520 thw@cpan.org
# Read Directory of 1st icon
# 20090520 thw@cpan.org
( $x, $y ) = unpack( 'cc', $read_io->( $stream, $length, $offset ));
# 20090520 thw@cpan.org
$id = 'ICO' if ( defined $x and defined $y );
# 20090520 thw@cpan.org
$x = 256 if defined $x and $x == 0;
# 20090520 thw@cpan.org
$y = 256 if defined $y and $y == 0;
# 20090520 thw@cpan.org
( $x, $y, $id );
# 20090520 thw@cpan.org
}
# 20090520 thw@cpan.org
sub cursize
# 20090520 thw@cpan.org
{
# 20090520 thw@cpan.org
my $stream = shift;
# 20090520 thw@cpan.org
my ( $x, $y, $id ) = ( undef, undef, "could not determine CUR size"
); # 20090520 thw@cpan.org
my ( $offset, $length ) = (6, 2);
# 20090520 thw@cpan.org
# Read Directory of 1st icon
# 20090520 thw@cpan.org
( $x, $y ) = unpack( 'cc', $read_io->( $stream, $length, $offset ));
# 20090520 thw@cpan.org
$id = 'CUR' if ( defined $x and defined $y );
# 20090520 thw@cpan.org
$x = 256 if defined $x and $x == 0;
# 20090520 thw@cpan.org
$y = 256 if defined $y and $y == 0;
# 20090520 thw@cpan.org
( $x, $y, $id );
# 20090520 thw@cpan.org
}
# 20090520 thw@cpan.org
I hope it is helpful...
------
Thomas Walloschke <thw@cpan.org>