| 1 | package Image::Size::FillFullSelect; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Image::Size; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 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 | 2 | 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 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 0 | my $hash; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if(defined($_[1])){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | 0 | ▶ | sub select{ #arg1=the image to use arg2=the max difference | ||||||||||||||||||||||||||
|
Subroutine
select: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 0 | 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 | ▶ | if(!defined($maxdiff)){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | $maxdiff=$self->{maxdiff}; | |||||||||||||||||||||||||||
| 88 | }; | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if (!$imageX){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | ▶ | if (!defined($xres)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | ▶ | if (!defined($maxdiff2)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ($ixydiff1 <= $maxdiff || $ixydiff2 <= $maxdiff){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ixydiff1 <= $maxdiff or $ixydiff2 <= $maxdiff
MC/DC0%0/2
$ixydiff1 <= $maxdiff or $ixydiff2 <= $maxdiff
$ixydiff1 <= $maxdiff
$ixydiff2 <= $maxdiff
Truth table0%0/3
A or B
A= $ixydiff1 <= $maxdiffB= $ixydiff2 <= $maxdiff
| |||||||||||||||||||||||||||||
| 111 | 0 | return "fill"; | |||||||||||||||||||||||||||
| 112 | }else{ | ||||||||||||||||||||||||||||
| 113 | 0 | return "full"; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if ($ixydiff1 <= $maxdiff || $ixydiff2 <= $maxdiff2){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ixydiff1 <= $maxdiff or $ixydiff2 <= $maxdiff2
MC/DC0%0/2
$ixydiff1 <= $maxdiff or $ixydiff2 <= $maxdiff2
$ixydiff1 <= $maxdiff
$ixydiff2 <= $maxdiff2
Truth table0%0/3
A or B
A= $ixydiff1 <= $maxdiffB= $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<< <vvelox at vvelox.net> >> | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =head1 BUGS | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | Please report any bugs or feature requests to C<bug-image-size-fillfullselect at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 131 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Image-Size-FillFullSelect>. 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<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Image-Size-FillFullSelect> | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | L<http://annocpan.org/dist/Image-Size-FillFullSelect> | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | L<http://cpanratings.perl.org/d/Image-Size-FillFullSelect> | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | L<http://search.cpan.org/dist/Image-Size-FillFullSelect> | ||||||||||||||||||||||||||||
| 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 | 2 | 1; # End of Image::Size::FillFullSelect | |||||||||||||||||||||||||||