| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Image::Info::ICO; |
|
2
|
|
|
|
|
|
|
$VERSION = '0.02'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# Copyright (C) 2009 Slaven Rezic. All rights reserved. |
|
5
|
|
|
|
|
|
|
# This package is free software; you can redistribute it and/or |
|
6
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
14
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
618
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub process_file { |
|
11
|
3
|
|
|
3
|
0
|
5
|
my($info, $fh) = @_; |
|
12
|
|
|
|
|
|
|
|
|
13
|
3
|
|
|
|
|
5
|
my $buf; |
|
14
|
3
|
50
|
|
|
|
30
|
if (read($fh, $buf, 6) != 6) { |
|
15
|
0
|
|
|
|
|
0
|
$info->push_info(0, 'error' => 'Short read (expected at least 6 bytes)'); |
|
16
|
0
|
|
|
|
|
0
|
return; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
11
|
$info->push_info(0, 'file_media_type' => 'image/x-icon'); # XXX or is there already an official vnd format? |
|
20
|
3
|
|
|
|
|
8
|
$info->push_info(0, 'file_ext' => 'ico'); |
|
21
|
|
|
|
|
|
|
|
|
22
|
3
|
|
|
|
|
13
|
my($no_icons) = unpack('v', substr($buf, 4, 2)); |
|
23
|
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
9
|
for my $img_no (0 .. $no_icons-1) { |
|
25
|
6
|
50
|
|
|
|
15
|
if (read($fh, $buf, 16) != 16) { |
|
26
|
0
|
|
|
|
|
0
|
$info->push_info(0, 'error' => "Short read while getting information for image at index $img_no"); |
|
27
|
0
|
|
|
|
|
0
|
return; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
6
|
|
|
|
|
22
|
my($width, |
|
30
|
|
|
|
|
|
|
$height, |
|
31
|
|
|
|
|
|
|
$colors, |
|
32
|
|
|
|
|
|
|
undef, # reserved |
|
33
|
|
|
|
|
|
|
undef, # $planes |
|
34
|
|
|
|
|
|
|
undef, # $bitcount |
|
35
|
|
|
|
|
|
|
undef, # $size_in_bytes |
|
36
|
|
|
|
|
|
|
undef, # $file_offset |
|
37
|
|
|
|
|
|
|
) = unpack('CCCCvvVV', $buf); |
|
38
|
6
|
50
|
|
|
|
13
|
if ($colors == 0) { $colors = 256 } |
|
|
6
|
|
|
|
|
89
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
6
|
|
|
|
|
16
|
$info->push_info($img_no, 'width', $width); |
|
41
|
6
|
|
|
|
|
11
|
$info->push_info($img_no, 'height', $height); |
|
42
|
6
|
|
|
|
|
11
|
$info->push_info($img_no, 'color_type', 'Indexed-RGB'); |
|
43
|
6
|
|
|
|
|
12
|
$info->push_info($img_no, 'colors', $colors); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Image::Info::ICO - Microsoft ICO support for Image::Info |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NOTES |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This module adds only support for MS Icon files, but not for cursor |
|
58
|
|
|
|
|
|
|
files. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Slaven Rezic |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
L<Image::Info> |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=begin register |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
MAGIC: /^\000\000\001\000/ |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This module supports the Microsoft Windows Icon Resource format |
|
73
|
|
|
|
|
|
|
(.ico). |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=end register |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |