APM: Perl GIF Integrity Check?

David Bluestein II dbii at interaction.net
Wed Dec 1 09:05:40 CST 2004


Wayne-

Thanks! That was it. For list purposes, here is the solution (using ImageMagick at least, I didn't check GD):

identify FILENAME

My bad files showed up as:

identify: Not a GIF image file (./xyz.GIF).

Automating it:

find . -type f -print0 | xargs -0 identify | grep -v PseudoC

gives me a reporting of bad files, which I save to file, and run Perl on to delete once I review it. (Some of filenames have a leading spaces I found out, so I had to use -print0 and xargs -0, instead of -print and xargs).

FYI, I run the grep -v at the end because good files show up as:

./abc.GIF[21] GIF 106x150+0+0 PseudoClass 256c 8-bit 8.9k 0.000u 0:01

So I strip those out automatically.

David

On Wed, Dec 01, 2004 at 08:17:06AM -0600, Wayne Walker wrote:
> I'd recommend using ImageMagick or GD.  you should be able to call
> load_image() or whatever and it should return success or failure.
> 
> That would validate the images I'd think.
> 
> This is all just a SWAG though. YMMV.
> 
> On Wed, Dec 01, 2004 at 01:03:24AM -0600, David Bluestein II wrote:
> > Okay, weird problem. I've got a directory of a pile of thumbnails
> > on server a, that is rsync'd to server b. Now some of the GIF files
> > on server a are bad (same filesize, modify date, etc.) due to a disk
> > problem and cannot be viewed. Is there a way in Perl that I can validate
> > which files on server a are not valid GIF files? I want to delete them
> > and restore from server b which has valid copies, but do not want to
> > restore all the files.
> > 
> > I basically need:
> > 
> > for (@filelist) {
> > unless (validatefileisvalidgif ($_) {
> > unlink $_;
> > }
> > }
> > 
> > Anyone know of a quick validefileisvalidgif function/module? I'd even settle for a shell script.
> > 
> > David
> 
> -- 
> 
> Wayne Walker
> wwalker at bybent.com                 Do you use Linux?!
> http://www.bybent.com              Get Counted!  http://counter.li.org/
> Perl - http://www.perl.org/        Perl User Groups - http://www.pm.org/
> Jabber:  wwalker at jabber.ntrc.net   AIM:     lwwalkerbybent
> IRC:     wwalker on freenode.net
> _______________________________________________
> Austin mailing list
> Austin at mail.pm.org
> http://mail.pm.org/mailman/listinfo/austin

-- 
David H. Bluestein II
President & Lead Developer        dbii at interaction.net
ii, inc.                          http://www.interaction.net
 -- Specializing in Designing Interactive Database Driven Websites -- 


More information about the Austin mailing list