I want to test if a file is a gif image or not.
Is it practicable using a module?
On 21 Feb 2004, at 19:03, John wrote:
I want to test if a file is a gif image or not.
Is it practicable using a module?
perldoc File::MMagic
#!/usr/bin/perl -w
use strict;
die "Usage: $0 directory\n" unless @ARGV > 0;
use File::Find;
use File::MMagic;
my $mm = File::MMagic->new;
find sub {
s" <[EMAIL PROTECTED]>
Sent: Saturday, February 21, 2004 9:09 PM
Subject: Re: Checking about gif
>
> On 21 Feb 2004, at 19:03, John wrote:
>
> > I want to test if a file is a gif image or not.
> >
> > Is it practicable using a module?
>
> perldoc File::MMa
plain
$mm->removeFileExts
Removes filename pattern checks. Specify one or more patterns. If no
pattern is specified, all are removed.
- Original Message -
From: "Jerry Rocteur" <[EMAIL PROTECTED]>
To: "John" <[EMAIL PROTECTED]>
Sent: Saturda
ecified, all are removed.
- Original Message -----
From: "Jerry Rocteur" <[EMAIL PROTECTED]>
To: "John" <[EMAIL PROTECTED]>
Sent: Saturday, February 21, 2004 9:37 PM
Subject: Re: Checking about gif
Ridiculous post your POD..
On 21 Feb 2004, at 20:25, John wrote:
John wrote:
>
> I want to test if a file is a gif image or not.
>
> Is it practicable using a module?
You can check whether a file purports to be a GIF file by
checking its first three bytes:
my $file = 'filename.gif';
my $type;
{
open my $fh, $file or die $!;
read $fh, $type, 3;
John wrote:
> I want to test if a file is a gif image or not.
print "filename to check: ";
my $filename = ;
chomp $filename;
open IN, $filename or die "Could not open file to check specs: $!";
binmode IN;
my $gif_label;
read (IN, $gif_label, 6);
chomp $gif_label;
if ($gif_label =~ /^GIF8[79]a/) {
Saturday, February 21, 2004 10:10 PM
Subject: Re: Checking about gif
> I'm going to top post because it is too long. No need to read the whole
> thing.
>
> I see what you're saying..
>
> I'm sorry for my reaction..
>
> I've written quite a few scripts since r
TED]>
Sent: Sunday, February 22, 2004 1:07 AM
Subject: Re: Checking about gif
> John wrote:
>
> > I want to test if a file is a gif image or not.
>
> print "filename to check: ";
> my $filename = ;
> chomp $filename;
> open IN, $filename or die "Could n
#!/usr/bin/perl -w
use strict;
die "Usage: $0 directory\n" unless @ARGV > 0;
use File::Find;
use File::MMagic;
my $mm = File::MMagic->new;
find sub {
return if -d $_ or -l $_;
my $type = $mm->checktype_filename($_);
return unless $type =~ /gif/i;
print "$File::Find::name: $t
10 matches
Mail list logo