View Single Post
Old 05-21-2002, 02:41 AM  
boldy
Macdaddy coder
 
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
here we go...

just install Image::Size as a perl module

perl -MCAN -e shell

install Image::Size

This script scansyour complete httpd tree for gifs and jpg files and checks them ... Like FAAAAAAASSSST!

Here's to code... done in 5 mins



#!/usr/bin/perl
use Image::Size;
use File::Find;

local @files;

#your httpd dir;

local $datapath="/home/httpd";

local @filelist;

get_files();

foreach (@filelist) {
$filename = $_;
@tmp = split (/\//,$filename);
$filename_last = $tmp[$#tmp];

($dummy,$ext) = split(/\./,$filename_last);
if ($ext =~ /gif/i || $ext =~ /jpg/i) {
push (@pics,$filename)
}
}

foreach (@pics) {
$filename=$_;
$W=0; $H=0;
($W,$H)=pic_info($filename);
if ($W == 0 || $H == 0) {
#your action...
print "$filename is NOT a valid jpg or gif ... \n";
}else{
print "$filename is a valid jpg or gif ... \n";
}
}
################################################## ############################
sub get_files {
print "Reading files for...\n";
@filelist = ();
@DIRLIST = ("$datapath");
find (\&process_file, @DIRLIST);
}
################################################## #####
sub process_file {
if (-f $_) {
push (@filelist,$File::Find::name, -d && '/');
}
}
################################################## #############################
sub pic_info {
$fullfilename=$_[0];

($x, $y) = imgsize("$fullfilename");
return ($x,$y);
}
__________________
MacDaddy Coder.

Last edited by boldy; 05-21-2002 at 02:47 AM..
boldy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote