I had a look at your reported error during
self-tests, and this is my analysis. An error
occurs during test number #17 in t/JPEG_5_exif_Thumbnail:
Show quoted text>> t/JPEG_5_exif_Thumbnail....# Testing APP1 Exif data routines (thumbnail)
>> t/JPEG_5_exif_Thumbnail....ok 16/26Use of uninitialized value in open
at /path/to/
Show quoted text>> Image-MetaData-JPEG-0.15/blib/lib/Image/MetaData/JPEG.pm line 134.
This test consists in a single line of code:
$image->set_Exif_data($thumb, 'THUMBNAIL');
where $thumb is a valid Image::MetaData::JPEG
object reference, previously created with:
$thumb = $classname->new($dataref);
What happens is that $thumb is passed to an internal
routine, set_Exif_thumbnail(), which can accept various
types of input, and whose goal is to produce and appro-
priately store a JPEG stream (a sequence of bytes). In
this case, therefore, the validity of the stream is
already guaranteed, and the routine only needs to extract
the image in a Perl scalar; this is done by
if ('Image::MetaData::JPEG' eq ref $dataref) {
my $r; $dataref->save(\ $r); $dataref = \ $r; }
This is not very important, it just shows who is
calling save(), which contains line 134 of JPEG.pm.
Anyway, save() is invoked with a reference to a scalar
as argument: the effect should be that the JPEG stream
is written into the scalar ($r). For some reason, this
works for me but not for you ... Now, you argue:
Show quoted text>> Disregard that last patch, as it turns out this was
>> a bigger problem than I realized. The 'filename' argument
>> being passed to the 'save' function is a REFERENCE,
>> but it's being treated like a scalar value. [...]
This is a misunderstanding; save() can accept either a
scalar or a reference to a scalar. If it is a plain
scalar it must contain a file name (and I agree that
I have to check that it is not the empty string, which
I will do in my next release); if it is a reference to
a scalar, the corresponding scalar is used as "in-memory
file". This is documented by 'perldoc -f open':
Since v5.8.0, perl has built using PerlIO by default.
Unless you've changed this (i.e. Configure -Uuseperlio),
you can open file handles to "in memory" files held in
Perl scalars via:
open($fh, '>', \$variable) || ..
This leads me to suppose that you are using an older
version of Perl (and that I should include an appropriate
"use VERSION" in my code), or that your version is not
standard configured (and I should check for this capability
to be present, which I don't know how to do presently).
Show quoted text>> I don't know if this was the intent or not, but going
>> with the pass-by-reference design I further patched the
>> routine to expect and verify the 'filename' variable as
>> a reference. [...]
>>
>> - $filename = $this->{filename} unless defined $filename;
>> + $filename = \$this->{filename} unless defined $filename;
>> + return undef unless ref($filename) eq 'SCALAR' && defined ($$filename);
As I said, this is not true. This variable has not a fixed
type: it can be a scalar or a reference to a scalar. If it
is undefined it must be replaced with a scalar, not with a
reference. This is the reason of all subsequent errors.
Show quoted text>> To follow-up: it's not clear what the tests are doing calling
>> the 'save' method with a reference (particularly when that
>> reference is to a unmodifiable constant), and furthermore calling
>> the 'new' method on the *class* with a reference to a constant.
>> For example, in t/JPEG_3_comments.t:
>> [...]
>> $bufferref = \ "dummy";
>> $image->save($bufferref);
>> $newim = $cname->new($bufferref);
>> [...]
>> What is this code trying to accomplish? I'm having trouble
>> figuring it out. The variable '$bufferref" here is a constant
>> value. [...]
Well, I agree that this code (a leftover) is a bit obscure,
and that the first line should be replaced by:
my $buffer;
$bufferref = \ $buffer;
However, I disagree with your idea that $bufferref is a constant.
It is a Perl variable holding the value of a reference; as such,
it is surely variable. Even $bufferref is not a constant, it is
just a scalar whose initial value (which is disregarded in the
call to open()) is "dummy".
In conclusion, if I take into account also the other errors
which you showed me in a private mail, I believe that your
Perl installation is either non-standard, or buggy or outdated
(maybe it is pre 5.8 ?). Could you give me more details on your
setup? Do you have the possibility to run the self-tests on a
different machine? By the way, I develop on a Debian system
with Perl 5.8.8. You can see other setups, where all self-tests
where passed, in the following web page:
http://cpantesters.perl.org/show/Image-MetaData-JPEG.html#Image-MetaData-JPEG-0.15
Best regards,
Stefano Bettelli