File Coverage

blib/lib/Filename/Image.pm
Criterion Covered Total %
statement 13 13 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 21 21 100.0


line stmt bran cond sub pod time code
1             package Filename::Image;
2              
3             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4             our $DATE = '2020-05-30'; # DATE
5             our $DIST = 'Filename-Image'; # DIST
6             our $VERSION = '0.003'; # VERSION
7              
8 1     1   70631 use 5.010001;
  1         10  
9 1     1   5 use strict;
  1         2  
  1         33  
10 1     1   6 use warnings;
  1         2  
  1         33  
11              
12 1     1   5 use Exporter qw(import);
  1         1  
  1         167  
13             our @EXPORT_OK = qw(check_image_filename);
14              
15             our $STR_RE = "djvu|jpeg|jpg2|svgz|tiff|wbmp|art|bmp|cdr|cdt|cpt|cr2|crw|djv|erf|gif|ico|ief|jng|jp2|jpe|jpf|jpg|jpm|jpx|nef|orf|pat|pbm|pcx|pgm|png|pnm|ppm|psd|ras|rgb|svg|tif|xbm|xpm|xwd"; # STR_RE
16              
17             our $RE = qr(\.(?:$STR_RE)\z)i;
18              
19             sub check_image_filename {
20 4     4 1 108 my %args = @_;
21              
22 4 100       53 $args{filename} =~ $RE ? {} : 0;
23             }
24              
25             1;
26             # ABSTRACT: Check whether filename indicates being an image file
27              
28             __END__