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

Hello

I want to resize .GIF images before displaying them in a Tk-based script. Of course it's possible to use Gimp and ImageMagick modules, but I want this script also to run on Windows. I believe these only run on non-Win32 platforms.

Does anyone know how to resize .GIF's on both Linux and Windows?

Jouke Visser, Perl 'Adept'

Replies are listed 'Best First'.
Re: Resizing images
by davorg (Chancellor) on Feb 12, 2001 at 17:49 UTC

    One slight warning. Resizing a GIF could well be seen as creating a new GIF. Doing this without buying a license from Unisys could well be illegal under the terms of their patents. See Lincoln' Stein's excellent Web Techniques article at http://www.webtechniques.com/archives/1999/12/webm/ for more details.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

        The UNISYS patent will, thankfully, expire in 2003. A Slashdot article has an interesting remark on this debacle.
Re: Resizing images
by $code or die (Deacon) on Feb 12, 2001 at 17:44 UTC

      And, while we're at it, so does the GIMP (albeit, not so stably. But it does work!). I'd still try Image::Magick tho' =)

      Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      But as far as I know (correct me if I'm wrong) I have to install ImageMagick first to be able to use the Perl package. That's not the kind of solution I'm looking for.

      I want to be able to distribute my software, and, if needed, provide additional Perl modules (more or less the way the Pronto mail client installer works), and I don't want to bother potential users with the need of installing some other software to use mine

      Jouke Visser, Perl 'Adept'
Re: Resizing images
by Corion (Pope) on Feb 12, 2001 at 17:45 UTC

    Image::Magick is also available for Win32, but the current binaries don't play well together with Perl 5.6. t0mas has compiled a set of working binaries though, so it must be possible :-)

    You can always shell out to the ImageMagick binaries - ImageMagick is fully portable.

Re: Resizing images
by ichimunki (Priest) on Feb 12, 2001 at 20:39 UTC
    In Tk, you can use the -subsample option in the copy() method call from a Photo widget to shrink any type of image you have loaded. This only allows for integer reduction ratios as far as I can tell, but is better than nothing. See an example of this in this node-- but note I've had little luck solving the memory issues. Your mileage may vary. This should not run afoul of any patents since you are only loading the image from a gif file, and not creating a new gif.
Re: Resizing images
by Anonymous Monk on Feb 13, 2001 at 05:35 UTC
    I use ImageMagick under Windows to resize graphics. I have a fairly simple script that loops through a folder full of graphics and applies an ImageMagick function(in this case resize) to each of them.

    You will need to download ActiveState version 5.x - the latest 6.x doesn't yet support ImageMagick. Install that on your Windows box, then use PPM to install ImageMagick.

    --Josh Everist

      Why not use the Image::Size module. I use it to resize the dimensions of all my graphics files in my institutions intranet. It's part of the standard Perl distribution for Win32 if you are on a Windows system. Perl is: "The last thing to break the camel's back!".
Re: Resizing images
by JSchmitz (Canon) on Feb 13, 2001 at 01:18 UTC
    How are you trying to display the image?
    Can't you just use pack?
    like
    $arrow = $mw->Photo(-file => "XCamel.gif");
    -image => $arrow)->pack;