PerlBear has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks:
The Question:
Is there a Perl Module that will conduct a verification of the integrity of a JPEG (or other) image file?
The Background:
Every five minutes I am downloading via ftp from an internet linked camera server a still JPEG image (roughly 27KB in size) and archiving it. This is done through an EXPECT and perl script.
The Problem:
99.9% of the time the download of the JPEG image is a success. However, every once and a while I get a corrupted or incomplete image.
Things Checked: The Need:
I need to be able to verify whether or not the JPEG that I just downloaded is good or not, if it is bad I will delete or replace it with a retry. I cannot base the check on size, because depending on what is seen the image size will vary.
ad grates:
I humbly thank you in advance for your insight and help.
  • Comment on Is there a Perl Module for image (JPEG) verification?

Replies are listed 'Best First'.
Re: Is there a Perl Module for image (JPEG) verification?
by dragonchild (Archbishop) on May 04, 2005 at 18:08 UTC
    Did you look on search.cpan.org? It takes 3 seconds. In particular, Image::TestJPG looks promising.

    • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
    • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
Re: Is there a Perl Module for image (JPEG) verification?
by chromatic (Archbishop) on May 04, 2005 at 18:06 UTC

    I know you said that checking the image size doesn't help, but I took that to mean that the size of the image can vary from request to request. Have you considered comparing the Content-Length header from the response to the received image size?