Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Scale image problems

by jerre_111 (Sexton)
on Mar 20, 2013 at 13:42 UTC ( #1024516=perlquestion: print w/replies, xml ) Need Help??
jerre_111 has asked for the wisdom of the Perl Monks concerning the following question:

Hi to you all, I'm seeking for some perl-wisdom if I may. I have some trouble with he "scale" function for an image. What I am trying to do is rescale an image (deuh...) But when I try to execute the perl script, I get the following error: "scale() called in void context - scale() returns the scaled image". I'm using this code to scale the image :


I was thinking maybe the problem could be my sliders.. I'm also using sliders on my mainwindow and I have made them like this :

 $hrScale = $mw->Scale();

followed by the configure command for the option for the slider. I don't know if it is right what I am assuming? Butt, I don't know what else is causing the error, and I don't know how to fix it. Many thanks already for your help!

Replies are listed 'Best First'.
Re: Scale image problems
by marto (Bishop) on Mar 20, 2013 at 13:51 UTC

    Rather than have people guess, please be specific and tell us what modules you're using to do this. If you're using Imager then the documentation and warning are correct, a new image is returned on successful transformation:

    my $newimg = $src->scale(xpixels=>400);

    From the docs:

    "Returns a new scaled image on success. The source image is not modified. Returns false on failure, check the errstr() method for the reason for failure. A mandatory warning is produced if scale() is called in void context. "

    Please read How do I post a question effectively?.

      Sorry, I was trying to be specific. I see now what I have overlooked.

      Thank you

Re: Scale image problems
by SuicideJunkie (Vicar) on Mar 20, 2013 at 18:02 UTC
    "scale() called in void context - scale() returns the scaled image"

    Yep. Looks like void context to me too.

    Why are you not saving the return value? The message is saying you should do:

    my $resized = $src->scale(xpixels=>400);

    Which puts the scale in scalar context

Re: Scale image problems
by Tux (Abbot) on Mar 20, 2013 at 13:45 UTC

    Is your $src valid to call scale () on? What module does provide your scale method?

    Enjoy, Have FUN! H.Merijn

      Sorry, forgot that part.

      I am using the Imager module to do this actions. Normally it is possible with this module, right?!

      this is the code I'm using to define  $src :

       $src = Imager->new(file => $image_file) or die Imager->errstr;

      Where the $image-file variabel is just the pad from where the image is located

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1024516]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2018-02-25 04:49 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (312 votes). Check out past polls.