i have a couple of questions on File::Find and Image::Info ;

1. why is my if statement not working to detect when i have a directory:
   last if ($file eq $dir);

2. why do i get this message when i finally do get to an image:
Not a CODE reference at ./bigimg2.pl line 39.
(this is displayed once an image is found)

and line 39 states:
       $type        =    $info->(file_ext);    # three letter image type

3. does it make any difference to Image::Info if i do the above or put single quotes ( ' ) like:
$type = $info->('file_ext');
because the former doesn't work with strict. and of coarse i am havving a problem with that line (and probably the following 4) so, i was just wondering if this could be a part of it...


any help would be appreciated.... the full code is as follows:

#!/usr/bin/perl

use warnings;
#use strict;
use File::Find;
#use File::Remove    qw(remove);
use Image::Info        qw(image_info);
use File::Scan;

# File::Find wanted function
sub wanted;

# variables
our ( $file, $dir );
*file =    *File::Find::name;
*dir    =    *File::Find::dir;


#print "Where are the pictures?\t"; #chomp( $indir = <STDIN> );

#print "The small pictures in $indir will be deleted";

File::Find::find( {wanted => \&wanted}, '/home/shawn/pic/test');
exit;

sub wanted {
print "$file being tested\n";
last if ($file eq $dir);
if ($file =~ /\.jpg\z/ or
$file =~ /\.tif\z/ or
$file =~ /\.bmp\z/ or
$file =~ /\.png\z/) {
my $info = image_info($file); # the attributes of the image file
if (my $error = $info->{error}) {
die "Can't parse image info: $error\n";
}
$type = $info->(file_ext); # three letter image type
$w = $info->(width); # pixel width
$h = $info->(height); # pixel height
$color = $info->(color_type); # color type
# delete small images
if( ($w < 200 && $h < 400) || ($w < 400 && $h < 200) ) {
print "being removed because of size";
unlink ($file) || warn "2 could not remove";
}
# delete images that try to be a different type from what they say
if ($type ne 'bmp' or
$type ne 'jpg' or
$type ne 'png' or
$type ne 'tif') {
print "being removed because of internal type";
unlink ($file) || warn "3 could not remove";
}
# delete all gray scale images
if ($color ne 'Gray' or
$color ne'GrayA') {
print "being removed because image is gray";
unlink ($file) || warn "4 could not remove";
}
# check images for viruses
# if ($scanres->scan(\$file) ) {
# if( $scanres->suspicious) {
# print "$file looks like it has a virus, delete/? /(Y//N/)";
# unlink ($file) if <STDIN> =~ /y|Y/ || warn "5 could not remove";
# }
# }
}
else { # delete every file exept listed image types.
print "being removed because of file extention";
unlink ($file) || warn "1 could not remove\n";
}
}



thanx darkhaven (aka - shawn wilson / ag4ve)


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to