| 1 | # $Id: ImageSize.pm 875 2002-10-29 11:05:17Z richardc $ | ||||||||||
| 2 | package File::Find::Rule::ImageSize; | ||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use File::Find::Rule; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use base qw( File::Find::Rule ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use vars qw/$VERSION @EXPORT/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | $VERSION = '0.03'; | |||||||||
| 9 | 1 | @EXPORT = @File::Find::Rule::EXPORT; | |||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use Number::Compare; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Image::Size qw( imgsize ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | my $dimension; | |||||||||
| 15 | 2 | ▶ | sub File::Find::Rule::image_x { $dimension = 'x'; &_match_dimension } | ||||||||
|
Subroutine
image_x: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | 2 | ▶ | sub File::Find::Rule::image_y { $dimension = 'y'; &_match_dimension } | ||||||||
|
Subroutine
image_y: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 17 | |||||||||||
| 18 | 4 | ▶ | sub _match_dimension { | ||||||||
|
Subroutine
_match_dimension: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 4 | my $self = shift()->_force_object; | |||||||||
| 20 | 4 | my $axis = $dimension; | |||||||||
| 21 | 4 | my @rules = map { Number::Compare->new($_) } @_; | |||||||||
| 22 | 12 | ▶ | $self->exec( sub { | ||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||
| 23 | 12 | my %h; @h{'x', 'y'} = imgsize($_); | |||||||||
| 24 | 12 | my $val = $h{ $axis }; | |||||||||
| 25 | 12 | ▶ | return unless defined $val; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 4 | ▶ | for (@rules) { return 1 if $_->($val) } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 2 | return; | |||||||||
| 28 | 4 | } ); | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 1 | 1; | |||||||||
| 32 | |||||||||||
| 33 | =head1 NAME | ||||||||||
| 34 | |||||||||||
| 35 | File::Find::Rule::ImageSize - rules for matching image dimensions | ||||||||||
| 36 | |||||||||||
| 37 | =head1 SYNOPSIS | ||||||||||
| 38 | |||||||||||
| 39 | use File::Find::Rule::ImageSize; | ||||||||||
| 40 | # find images bigger than 20x20 | ||||||||||
| 41 | my @images = find( file => image_x => '>20', image_y => '>20', in => '.' ); | ||||||||||
| 42 | |||||||||||
| 43 | =head1 DESCRIPTION | ||||||||||
| 44 | |||||||||||
| 45 | File::Find::Rule::ImageSize interfaces Image::Size to File::Find::Rule | ||||||||||
| 46 | enabling you to find files based upon their dimensions. | ||||||||||
| 47 | Number::Compare is used so that the sizes may be relative values. | ||||||||||
| 48 | |||||||||||
| 49 | =head2 ->image_x( @sizes ) | ||||||||||
| 50 | =head2 ->image_y( @sizes ) | ||||||||||
| 51 | |||||||||||
| 52 | Match only things with their dimensions constrained by @sizes. The | ||||||||||
| 53 | specification can be a relative, as implemented by L<Number::Compare>. | ||||||||||
| 54 | |||||||||||
| 55 | =head1 AUTHOR | ||||||||||
| 56 | |||||||||||
| 57 | Richard Clamp <richardc@unixbeard.net>, from an idea by Mark Fowler. | ||||||||||
| 58 | |||||||||||
| 59 | =head1 COPYRIGHT | ||||||||||
| 60 | |||||||||||
| 61 | Copyright (C) 2002 Richard Clamp. All Rights Reserved. | ||||||||||
| 62 | |||||||||||
| 63 | This module is free software; you can redistribute it and/or modify it | ||||||||||
| 64 | under the same terms as Perl itself. | ||||||||||
| 65 | |||||||||||
| 66 | =head1 SEE ALSO | ||||||||||
| 67 | |||||||||||
| 68 | L<File::Find::Rule>, L<Number::Compare>, L<Image::Size> | ||||||||||
| 69 | |||||||||||
| 70 | =cut | ||||||||||