Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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 :

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

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!

Comment on Scale image problems
Select or Download Code
Re: Scale image problems
by Tux (Monsignor) 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

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 (Priest) on Mar 20, 2013 at 18:02 UTC
    $src->scale(xpixels=>400);
    "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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1024516]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2015-07-07 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls