Fellow Monks:
I am wondering if there is anyone out there amongst my brethern that have had dealings with the Perl module:
Image::TestJPG.
This module was recommended to me in a previous post as having the primary function of verify the integrity of
a JPEG image file, (which is precisely what I want to do).
With a slight little bit of tweaking to see what precisely (with the variables), what things were doing, I ran the test code provided with the documentation on a JPEG image file that was known to be good.
#!/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";
}
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.
My initial results on the test of the "good JPEG" returned the results of "... jpeg data contains errors ..." . A new this was not correct because a knew for a fact that my JPEG was good. So... I suspected that something was fishy, so I added a diagnostic line to see what was actually being returned by the subroutine:
my $rv = Image::TestJPG::testJPG($jpgData, $length);
print "RV: $rv\n";
If things were working properly according to the documentation, I should have gotten a 1 or a 0.
Instead all I got was:
Use of uninitialized value in concatenation (.) or string at ./CCIMGVE
+Rtest.pl line 20.
RV:
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:
binmode JPEG;
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.
It would be really grat if I could get this module to work like it is supposed to according to the documentation.
FYI: The OS that I am running this is Red Hat Linux 9 and the Perl Version is 5.8.0 .
Thank you in advance for you help, insight and wisdom!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.