marcz908 has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to scale the size of an image with perl Tk? I tried passing the -height and/or -width options to Photo(), but when I display it with Label() it just shows a chunk of the image, not the whole thing, and not scaled at all.

$mw->Photo("image1", -data => $imgdata{'image1'}, -height = 200); $mw->Label(-image => "image1")->pack();

Is there a way to do this in Tk, or do I have to scale the image myself with Image Magick or GD? I thought that being able to scale the image would save alot of time as opposed to creating several versions of the image in different sizes.

Thank you!

Replies are listed 'Best First'.
Re: can you scale an image to size with Tk's Photo method?
by gri6507 (Deacon) on Jun 08, 2004 at 21:11 UTC
    The way I've handled this in the past was to either create a new picture just just the size that I need and use that for the Label. If, however, you want to scale it on the fly, I believe you will have to go with Image Magick or GD
      If, however, you want to scale it on the fly, I believe you will have to go with Image Magick or GD
      As all who read pod know, i'm glad to say, thats not so => Tk::Photo, Resizing images && Tk

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

        Unfortunately the general answer is no. Rescaling is only possible in integral steps using the -zoom and -subsample options. For arbitrary resizing one has to use external tools.
        Did the Copy() method exist in Tk 800.022? That's what I'm stuck dealing with.