line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::Size::FillFullSelect; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21470
|
use Image::Size; |
|
1
|
|
|
|
|
5242
|
|
|
1
|
|
|
|
|
77
|
|
4
|
1
|
|
|
1
|
|
11
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
369
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Image::Size::FillFullSelect - Choose wether a image fill setting for a image should be fill or full. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.1.0 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Decides if the fill setting for a image should be either fill, |
23
|
|
|
|
|
|
|
in meaning the image should be resized to fix the screen, or full |
24
|
|
|
|
|
|
|
which means it should be scaled to fit the screen. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Image::Size::FillFullSelect; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $iffs = Image::Size::FillFullSelect->new(); |
29
|
|
|
|
|
|
|
my $FFselection = $iffs->select("someImage.gif"); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 FUNCTIONS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 new |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This creates a new Image::Size::FillFullSelect object. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
It takes one optional arguement, which is a integer that |
38
|
|
|
|
|
|
|
represents the maximum difference between the X and Y |
39
|
|
|
|
|
|
|
dimensions of a image. The default is .2, which means |
40
|
|
|
|
|
|
|
the maximum differce between either can be 20%. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
45
|
0
|
|
|
0
|
1
|
|
my $hash; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
48
|
0
|
|
|
|
|
|
$hash={maxdiff=>$_[1]}; |
49
|
|
|
|
|
|
|
}else{ |
50
|
0
|
|
|
|
|
|
$hash={maxdiff=>".2"}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
bless $hash; |
54
|
0
|
|
|
|
|
|
return $hash; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 select |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This makes the selection between the two. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
It takes two arguements and three optional ones. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
The first arguement is the image. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The second is the max difference when the size of |
66
|
|
|
|
|
|
|
the picture is used to devide each other. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The third is continuation of the second, but defaults |
69
|
|
|
|
|
|
|
what ever the second is if it is not specified. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The fourth is comparative X resolution to use. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The fifth is the comparative Y resolution to use. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Upon a error, it returns undef. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $filltype=$iffs->select($image, '.2', undef, '800', '600'); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub select{ #arg1=the image to use arg2=the max difference |
82
|
0
|
|
|
0
|
1
|
|
my ($self, $image, $maxdiff, $maxdiff2, $xres, $yres)=@_; |
83
|
0
|
|
|
|
|
|
my ($imageX, $imageY)=imgsize("$image"); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#use the default if it is defined. |
86
|
0
|
0
|
|
|
|
|
if(!defined($maxdiff)){ |
87
|
0
|
|
|
|
|
|
$maxdiff=$self->{maxdiff}; |
88
|
|
|
|
|
|
|
}; |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
|
if (!$imageX){ |
91
|
0
|
|
|
|
|
|
warn($image." is not a image\n"); |
92
|
0
|
|
|
|
|
|
return undef; |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
#this needs done twice since one direction only can't be trusted... |
95
|
0
|
|
|
|
|
|
my $ixydiff1; |
96
|
|
|
|
|
|
|
my $ixydiff2; |
97
|
0
|
0
|
|
|
|
|
if (!defined($xres)) { |
98
|
0
|
|
|
|
|
|
$ixydiff1=$imageX/$imageY - 1; #gets the scale difference... |
99
|
0
|
|
|
|
|
|
$ixydiff1=abs($ixydiff1); #make the scale differ into a absolute value for easier use |
100
|
0
|
|
|
|
|
|
$ixydiff2=$imageY/$imageX - 1; #gets the scale in the other directions... |
101
|
0
|
|
|
|
|
|
$ixydiff2=abs($ixydiff2); #abs the other one also |
102
|
|
|
|
|
|
|
}else { |
103
|
0
|
|
|
|
|
|
$ixydiff1=$xres/$imageY - 1; #gets the scale difference... |
104
|
0
|
|
|
|
|
|
$ixydiff1=abs($ixydiff1); #make the scale differ into a absolute value for easier use |
105
|
0
|
|
|
|
|
|
$ixydiff2=$yres/$imageX - 1; #gets the scale in the other directions... |
106
|
0
|
|
|
|
|
|
$ixydiff2=abs($ixydiff2); #abs the other one also |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
|
if (!defined($maxdiff2)) { |
110
|
0
|
0
|
0
|
|
|
|
if ($ixydiff1 <= $maxdiff || $ixydiff2 <= $maxdiff){ |
111
|
0
|
|
|
|
|
|
return "fill"; |
112
|
|
|
|
|
|
|
}else{ |
113
|
0
|
|
|
|
|
|
return "full"; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
0
|
0
|
0
|
|
|
|
if ($ixydiff1 <= $maxdiff || $ixydiff2 <= $maxdiff2){ |
117
|
0
|
|
|
|
|
|
return "fill"; |
118
|
|
|
|
|
|
|
}else{ |
119
|
0
|
|
|
|
|
|
return "full"; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 BUGS |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
131
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
132
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SUPPORT |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
perldoc Image::Size::FillFullSelect |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
You can also look for information at: |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 4 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * CPAN Ratings |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * Search CPAN |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Copyright 2008 Zane C. Bowers, all rights reserved. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
172
|
|
|
|
|
|
|
under the same terms as Perl itself. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; # End of Image::Size::FillFullSelect |