PerlBear has asked for the wisdom of the Perl Monks concerning the following question:
According to the documentation for this module, the subroutine testJPG should return a value of 0 if the JPEG is bad, and 1 if it is good; thus in this case setting the variable $rv to 0 or 1 accordingly.#!/usr/bin/perl -w use strict; use Image::TestJPG; my $file="/main/images/temp/image.jpg"; # read data from a file open(JPEG, "$file") or die "Can't open $file : $!\n"; my $jpgData = <JPEG>; close(JPEG); my $length=length($jpgData); print "LENGTH: $length\n"; # test the data my $rv = Image::TestJPG::testJPG($jpgData,$length); print "RV: $rv\n"; # do something based on the return value if($rv) { print " ... jpeg data is valid ...\n"; } else { print "... jpeg data contains errors ...\n"; }
If things were working properly according to the documentation, I should have gotten a 1 or a 0. Instead all I got was:my $rv = Image::TestJPG::testJPG($jpgData, $length); print "RV: $rv\n";
This implied to me that something inside the subroutine was going wrong, or perhaps I was missing some subtlety not known to me. At one point I added:Use of uninitialized value in concatenation (.) or string at ./CCIMGVE +Rtest.pl line 20. RV:
just after the open statement for reading in the image file, with the line of thought of forcing perhaps the file read into binary; however, this made no difference.binmode JPEG;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Insight Into Image::TestJPG Module needed
by Joost (Canon) on May 09, 2005 at 13:40 UTC | |
Re: Insight Into Image::TestJPG Module needed
by davidrw (Prior) on May 09, 2005 at 13:37 UTC | |
Re: Insight Into Image::TestJPG Module needed
by Anonymous Monk on May 09, 2005 at 13:12 UTC |