Hi,

I am getting the error in the title when calling the Image::Seek module from my script. My script is basically a rehash of the module's suggested code.

Here's the error again:

Can't call method "scaleY" on an undefined value at C:/strawberry/perl +/site/lib/ Image/Seek.pm line 137.
Here's my code:
#!/usr/local/bin/perl use Imager; use Image::Seek qw(loaddb add_image query_id savedb); loaddb("haar.db"); my $img = Imager->new(); $img->open(file => "photo-216.jpg"); add_image($img, 216); savedb("haar.db"); my @results = query_id(216); # What looks like this photo?
Here's the section of the Image::Seek module causing the issue:
sub add_image_imager { my ($img, $id) = @_; my ($reds, $blues, $greens); require Imager; my $thumb = $img->scaleX(pixels => 128)->scaleY(pixels => 128); for my $y (0..127) { my @cols = $thumb->getscanline(y => $y); for (@cols) { my ($r, $g, $b) = $_->rgba; $reds .= chr($r); $blues .= chr($b); $greens .= chr($g); } } addImage($id, $reds, $greens, $blues); }

Line 137 is:

my $thumb = $img->scaleX(pixels => 128)->scaleY(pixels => 128);

If I remove

->scaleY(pixels => 128)

then line 129:

my @cols = $thumb->getscanline(y => $y);

gives me essentially the same error.

At this point I'm just trying to add one image to the database. There is an image in the directory where I'm running the script to add the image, named "photo-216.jpg". If I change the name to "photo-1.jpg" or "photo-0.jpg" and change the corresponding "add_image" and "query_id" to respectively 1 or 0, it's the same result.

I do have a database that is 385 kb big that comes from running makedb.pl below, but it is filled with null characters. I renamed this "haar.db". This is the database that gives me the error. If I recreate the file as an empty one, then the script hangs and after a couple of minutes, it give this message: "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." If there is no "haar.db" the file still gives me the error in this post's title and unlike running makedb.pl, gives me no database named "haar.db".

By the way I get multiple examples of this post's title error also when trying to run this database filling script: http://www.drk7.jp/pub/imgseek/t/makedb.pl.txt. I obviously removed the .txt extension before trying it. The makedb.pl script is from this Japanese site: from this site: http://www.drk7.jp/MT/archives/001258.html.

Thanks much

If I run makedb.pl I get 362 instances of the error for 2423 stamps images in the directory. The 2423 stamps is the number after removing the "small" thumbnail versions which I though might be causing the issue. Could it be, some of the images are less than 128 pixels and that is the issue? But why doesn't the database get filled with other than the null characters?...Unless they are not really null even though Notebook++ says they are. Also note my images are of stamps which are only sometimes perfect squares. Sometimes they are "landscape" sometimes "portrait".

In reply to Can't call method "scaleY" on an undefined value at C:/strawberry/perl/site/lib/ Image/Seek.pm line 137. by socrtwo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.