Resizing images in a Tcl script - TCL

This is a discussion on Resizing images in a Tcl script - TCL ; My app needs to be able to resize images on the fly. Tk's native "$img copy -subsample" option yields poor results, and will only scale images down, not up. What other options are available? I've tried Pixane ( http://www.evolane.com/software/pixane/pixane.html ) ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17

Resizing images in a Tcl script

  1. Default Resizing images in a Tcl script

    My app needs to be able to resize images on the fly. Tk's native
    "$img copy -subsample" option yields poor results, and will only scale
    images down, not up. What other options are available?

    I've tried Pixane (http://www.evolane.com/software/pixane/pixane.html)
    which appears to do the job both reasonably well, and reasonably
    quickly; BUT. It doesn't coexist well with the Img extension. Once
    I've loaded Pixane, I can't load the Img extension; I get the error "
    couldn't use "jpegtcl": please upgrade to at least version 6a". If I
    load the Img extension first, followed by Pixane, then calls like this
    fail:

    image create photo -file foo.jpg

    Pixane has a way to link a Pixane image to a Tk photo image;
    consequently, I can use Pixane to load JPEG images into Tk photo
    images. This, however, is horribly, horribly slow.

    I've heard of TclMagick, but I don't know how good it is; my past
    attempts to get a copy have (IIRC) led me into dependency hell. It
    certainly isn't in the teapot.

    Any thoughts?

  2. Default Re: Resizing images in a Tcl script

    will@wjduquette.com wrote:
    > My app needs to be able to resize images on the fly. Tk's native
    > "$img copy -subsample" option yields poor results, and will only scale
    > images down, not up. What other options are available?
    >
    > I've tried Pixane (http://www.evolane.com/software/pixane/pixane.html)
    > which appears to do the job both reasonably well, and reasonably
    > quickly; BUT. It doesn't coexist well with the Img extension. Once
    > I've loaded Pixane, I can't load the Img extension; I get the error "
    > couldn't use "jpegtcl": please upgrade to at least version 6a". If I
    > load the Img extension first, followed by Pixane, then calls like this
    > fail:
    >
    > image create photo -file foo.jpg
    >
    > Pixane has a way to link a Pixane image to a Tk photo image;
    > consequently, I can use Pixane to load JPEG images into Tk photo
    > images. This, however, is horribly, horribly slow.
    >
    > I've heard of TclMagick, but I don't know how good it is; my past
    > attempts to get a copy have (IIRC) led me into dependency hell. It
    > certainly isn't in the teapot.
    >
    > Any thoughts?


    Tk Magik (aka the Tcl extension to ImageMagik)?

    --
    +------------------------------------------------------------------------+
    | Gerald W. Lester |
    |"The man who fights for his ideals is the man who is alive." - Cervantes|
    +------------------------------------------------------------------------+

  3. Default Re: Resizing images in a Tcl script

    On Nov 5, 7:45 am, w...@wjduquette.com wrote:
    > Pixane has a way to link a Pixane image to a Tk photo image;
    > consequently, I can use Pixane to load JPEG images into Tk photo
    > images.  This, however, is horribly, horribly slow.


    Aha! What I was doing was using "pixane create -tkphoto $img" to link
    a Pixane image to a Tk photo image; then, any operations on the Pixane
    image appear in the Tk image as well. This is, as I say, horribly
    slow.

    However, it develops that Pixane also has a "pixcopy" command, defined
    when Tk is available, that converts Pixane images to Tk images and
    back again; this is much faster. I'm not sure it's a perfect
    solution,
    but it's better.


  4. Default Re: Resizing images in a Tcl script

    On Nov 5, 7:50 am, "Gerald W. Lester" <Gerald.Les...@cox.net> wrote:
    > w...@wjduquette.com wrote:
    > > I've heard of TclMagick, but I don't know how good it is; my past
    > > attempts to get a copy have (IIRC) led me into dependency hell.  It
    > > certainly isn't in the teapot.

    >
    > > Any thoughts?

    >
    > Tk Magik (aka the Tcl extension to ImageMagik)?


    Hi, Gerald! Have you actually used Tk Magik (I thought it was
    TclMagick?)
    What's your experience been with it?

  5. Default Re: Resizing images in a Tcl script

    will@wjduquette.com wrote:
    > My app needs to be able to resize images on the fly. Tk's native
    > "$img copy -subsample" option yields poor results, and will only scale
    > images down, not up. What other options are available?
    >
    > I've tried Pixane (http://www.evolane.com/software/pixane/pixane.html)
    > which appears to do the job both reasonably well, and reasonably
    > quickly; BUT. It doesn't coexist well with the Img extension. Once
    > I've loaded Pixane, I can't load the Img extension; I get the error "
    > couldn't use "jpegtcl": please upgrade to at least version 6a". If I
    > load the Img extension first, followed by Pixane, then calls like this
    > fail:
    >
    > image create photo -file foo.jpg
    >
    > Pixane has a way to link a Pixane image to a Tk photo image;
    > consequently, I can use Pixane to load JPEG images into Tk photo
    > images. This, however, is horribly, horribly slow.
    >
    > I've heard of TclMagick, but I don't know how good it is; my past
    > attempts to get a copy have (IIRC) led me into dependency hell. It
    > certainly isn't in the teapot.
    >
    > Any thoughts?


    Will,

    I've started using TkCximage in my apps:

    http://amsn.svn.sourceforge.net/view...ils/TkCximage/

    It's a Tk interface to the Cximage library
    (http://www.xdp.it/cximage.htm). Cximage can do all kinds of cool things
    with a variety of image formats--not just read them but manipulate them.

    The aMSN folks (http://www.amsn-project.net) developed TkCximage to use
    in that app, for the reasons you outline--on-the-fly-image-resizing, as
    well as other manipulations. TkImg doesn't provide this.

    TkCximage hasn't been adopted outside of aMSN. I persuaded them to make
    it available under the LGPL, which they've done. A standalone package
    isn't available. Binary libs for Windows and Mac are part of aMSN's SVN
    archive, and you can build it for *Nix from the SVN archive (see
    http://amsn.sourceforge.net/wiki/tik...n+Instructions
    for instructions--running "configure" will build TkCximage if you have
    libpng and libjpeg installed, those are dependencies).

    I'm going to put TkCximage through more paces on my apps before
    "evangelizing" it more, but since you're looking for what it provides, I
    hope it helps you!

    Kevin

    --
    Kevin Walzer
    Code by Kevin
    http://www.codebykevin.com

  6. Default Re: Resizing images in a Tcl script

    will@wjduquette.com wrote:
    > On Nov 5, 7:50 am, "Gerald W. Lester" <Gerald.Les...@cox.net> wrote:
    >> w...@wjduquette.com wrote:
    >>> I've heard of TclMagick, but I don't know how good it is; my past
    >>> attempts to get a copy have (IIRC) led me into dependency hell. It
    >>> certainly isn't in the teapot.
    >>> Any thoughts?

    >> Tk Magik (aka the Tcl extension to ImageMagik)?

    >
    > Hi, Gerald! Have you actually used Tk Magik (I thought it was
    > TclMagick?)
    > What's your experience been with it?


    Used it once several years ago. Seemed to work, but did not stress test it.

    And yeap, it is TclMagik.

    --
    +------------------------------------------------------------------------+
    | Gerald W. Lester |
    |"The man who fights for his ideals is the man who is alive." - Cervantes|
    +------------------------------------------------------------------------+

  7. Default Re: Resizing images in a Tcl script

    On Nov 5, 7:45 am, w...@wjduquette.com wrote:
    > My app needs to be able to resize images on the fly. Tk's native
    > "$img copy -subsample" option yields poor results, and will only scale
    > images down, not up. What other options are available?
    >
    > I've tried Pixane (http://www.evolane.com/software/pixane/pixane.html)
    > which appears to do the job both reasonably well, and reasonably
    > quickly; BUT. It doesn't coexist well with the Img extension. Once
    > I've loaded Pixane, I can't load the Img extension; I get the error "
    > couldn't use "jpegtcl": please upgrade to at least version 6a". If I
    > load the Img extension first, followed by Pixane, then calls like this
    > fail:
    >
    > image create photo -file foo.jpg
    >
    > Pixane has a way to link a Pixane image to a Tk photo image;
    > consequently, I can use Pixane to load JPEG images into Tk photo
    > images. This, however, is horribly, horribly slow.
    >
    > I've heard of TclMagick, but I don't know how good it is; my past
    > attempts to get a copy have (IIRC) led me into dependency hell. It
    > certainly isn't in the teapot.
    >
    > Any thoughts?


    http://wiki.tcl.tk/11924
    is good code for me.

    Also note that there is both
    Tclmagick and Tkmagick. Tclmagick doesn't
    require tk and can't work with tk images.
    tkmagick is basically a copy bridge between
    image magick and Tk images (in memory)
    Finally, there is a largish update of tclmagick
    adding api calls. The new version is tclwand.

  8. Default Re: Resizing images in a Tcl script

    On Nov 5, 11:52 am, Roy Terry <royte...@earthlink.net> wrote:
    > On Nov 5, 7:45 am, w...@wjduquette.com wrote:
    >
    >
    >
    > > My app needs to be able to resize images on the fly.  Tk's native
    > > "$img copy -subsample" option yields poor results, and will only scale
    > > images down, not up.  What other options are available?

    >
    > > I've tried Pixane (http://www.evolane.com/software/pixane/pixane.html)
    > > which appears to do the job both reasonably well, and reasonably
    > > quickly; BUT.  It doesn't coexist well with the Img extension.  Once
    > > I've loaded Pixane, I can't load the Img extension; I get the error "
    > > couldn't use "jpegtcl": please upgrade to at least version 6a".  If I
    > > load the Img extension first, followed by Pixane, then calls like this
    > > fail:

    >
    > >    image create photo -file foo.jpg

    >
    > > Pixane has a way to link a Pixane image to a Tk photo image;
    > > consequently, I can use Pixane to load JPEG images into Tk photo
    > > images.  This, however, is horribly, horribly slow.

    >
    > > I've heard of TclMagick, but I don't know how good it is; my past
    > > attempts to get a copy have (IIRC) led me into dependency hell.  It
    > > certainly isn't in the teapot.

    >
    > > Any thoughts?

    >
    > http://wiki.tcl.tk/11924
    > is good code for me.


    I second that. I needed something for image rotation and
    I found tcl magick too bulky for such a simple task.

    Only problem is that I haven't been able to get it to
    work under Unix. Has anybody had any luck?

    Keith



  9. Default Re: Resizing images in a Tcl script

    On Wed, 5 Nov 2008, Roy Terry wrote:

    > Date: Wed, 5 Nov 2008 08:52:18 -0800 (PST)
    > From: Roy Terry <royterry@earthlink.net>
    > Newsgroups: comp.lang.tcl
    > Subject: Re: Resizing images in a Tcl script
    >
    > On Nov 5, 7:45 am, w...@wjduquette.com wrote:
    >> My app needs to be able to resize images on the fly. Tk's native
    >> "$img copy -subsample" option yields poor results, and will only scale
    >> images down, not up. What other options are available?
    >>
    >> I've tried Pixane (http://www.evolane.com/software/pixane/pixane.html)
    >> which appears to do the job both reasonably well, and reasonably
    >> quickly; BUT. It doesn't coexist well with the Img extension. Once
    >> I've loaded Pixane, I can't load the Img extension; I get the error "
    >> couldn't use "jpegtcl": please upgrade to at least version 6a". If I
    >> load the Img extension first, followed by Pixane, then calls like this
    >> fail:
    >>
    >> image create photo -file foo.jpg
    >>
    >> Pixane has a way to link a Pixane image to a Tk photo image;
    >> consequently, I can use Pixane to load JPEG images into Tk photo
    >> images. This, however, is horribly, horribly slow.
    >>
    >> I've heard of TclMagick, but I don't know how good it is; my past
    >> attempts to get a copy have (IIRC) led me into dependency hell. It
    >> certainly isn't in the teapot.
    >>
    >> Any thoughts?

    >
    > http://wiki.tcl.tk/11924
    > is good code for me.
    >
    > Also note that there is both
    > Tclmagick and Tkmagick. Tclmagick doesn't
    > require tk and can't work with tk images.
    > tkmagick is basically a copy bridge between
    > image magick and Tk images (in memory)
    > Finally, there is a largish update of tclmagick
    > adding api calls. The new version is tclwand.


    One thing you might want to consider is extracting the thumbnail from the
    exif data to scale "downwards", and only "scale" if necessary ... that is,
    to scale fast, don't scale at all ...

    Actually, tkMagick is unnecessary, as all one needs is to copy the blob
    from tclMagick into a tk image -- note wand2Image below ... :

    proc blob2wand { wand blob } {
    $wand readblob $blob
    return $wand
    }
    proc wand2Image { wand img } {
    $img put [ $wand writeblob ]
    }
    proc resize { wand width height } {
    $wand resize $width $height
    }
    proc getImage { path } {
    set ret [image create photo]
    $ret read $path
    return $ret
    }
    proc putImage { img path } {
    return [$img write $path]
    }
    proc putWand { wand path } {
    return [$wand write $path]
    }

    .... As for building tclMagick ... once you have a working version of
    ImageMagick, you can adapt the following script to build only the required
    parts of tclMagick ... You don't need the entire autotools config/make to
    do so ...

    wnd=/usr/local/bin/Wand-config
    #CC=mingw32-gcc
    CC=gcc
    $CC -shared -DUSE_TCL_STUBS -fPIC -DUSE_TK_STUBS -DUSE_TK_STUBS -I. \
    -I/usr/local/include -L/usr/local/lib -L/usr/lib \
    `$wnd --ldflags --libs` \
    -L /usr/local/lib -ltclstub8.5 \
    -o tclmagick.so -O2 -DNDEBUG TclMagick.c
    # -o tclmagick.so -O2 -DNDEBUG -Wl,-s TclMagick.c


    If you are on windows, you'll need MingW or CygWin ...

    HTH ...
    Cheers,
    Rob
    ---- Posted via Pronews.com - Premium Corporate Usenet News Provider ----
    http://www.pronews.com offers corporate packages that have access to 100,000+ newsgroups

  10. Default Re: Resizing images in a Tcl script

    On Nov 5, 8:52 am, Roy Terry <royte...@earthlink.net> wrote:
    > On Nov 5, 7:45 am, w...@wjduquette.com wrote:
    > > My app needs to be able to resize images on the fly.  Tk's native
    > > "$img copy -subsample" option yields poor results, and will only scale
    > > images down, not up.  What other options are available?

    >
    >
    > http://wiki.tcl.tk/11924
    > is good code for me.


    That sounds just about perfect...if it works on Linux.

+ Reply to Thread
Page 1 of 2 1 2 LastLast