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?
0
will181 (163)
11/5/2008 3:45:18 PM
comp.lang.tcl 22564 articles. 13 followers. Post Follow

16 Replies
347 Views

Similar Articles

[PageSpeed] 47
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|
+------------------------------------------------------------------------+
0
Gerald.Lester (2014)
11/5/2008 3:50:24 PM
On Nov 5, 7:45=A0am, 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. =A0This, 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.

0
will181 (163)
11/5/2008 4:01:46 PM
On Nov 5, 7:50=A0am, "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. =A0It
> > 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?
0
will181 (163)
11/5/2008 4:02:47 PM
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/viewvc/amsn/trunk/amsn/utils/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/tiki-index.php?page=Installation+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
0
kw564 (720)
11/5/2008 4:12:12 PM
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|
+------------------------------------------------------------------------+
0
Gerald.Lester (2014)
11/5/2008 4:39:42 PM
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.
0
royterry (360)
11/5/2008 4:52:18 PM
On Nov 5, 11:52=A0am, 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. =A0Tk's native
> > "$img copy -subsample" option yields poor results, and will only scale
> > images down, not up. =A0What 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. =A0It doesn't coexist well with the Img extension. =A0Onc=
e
> > 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". =A0If I
> > load the Img extension first, followed by Pixane, then calls like this
> > fail:
>
> > =A0 =A0image 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. =A0This, 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. =A0It
> > 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


0
kvetter (178)
11/5/2008 5:08:08 PM
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
0
Spam159 (460)
11/5/2008 5:09:33 PM
On Nov 5, 8:52=A0am, 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. =A0Tk's native
> > "$img copy -subsample" option yields poor results, and will only scale
> > images down, not up. =A0What other options are available?
>
>
> http://wiki.tcl.tk/11924
> is good code for me.

That sounds just about perfect...if it works on Linux.
0
will181 (163)
11/5/2008 5:23:29 PM
Hi Rob,

to extract the thumbnail from the EXIF data I used simply the tcllib
jpeg package and stored the thumbnail into a file.

Ok - if the EXIF orientation tag tells, that the thumbnail should be
rotated, than I used pixane to rotate the thumbnail before saving it.

I also tried Image/TclMagick, but while building and using starpacks a
lot I ran into problems with the DLL/registry dependencies on systems,
where ImageMagick wasn't installed properly.
Pixane worked right out of the (starpack) box. And it worked really
quick!

But I never needed Linux/Unix support, so I don't know about the Linux/
Unix support of pixane.

Best Regards,

Martin

On Nov 5, 6:09=A0pm, S...@ControlQ.com wrote:
> On Wed, 5 Nov 2008, Roy Terry wrote:
> > Date: Wed, 5 Nov 2008 08:52:18 -0800 (PST)
> > From: Roy Terry <royte...@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. =A0Tk's native
> >> "$img copy -subsample" option yields poor results, and will only scale
> >> images down, not up. =A0What 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. =A0It doesn't coexist well with the Img extension. =A0On=
ce
> >> 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". =A0If =
I
> >> load the Img extension first, followed by Pixane, then calls like this
> >> fail:
>
> >> =A0 =A0image 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. =A0This, 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. =A0It
> >> 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 ... :
>
> =A0 =A0proc blob2wand { wand blob } {
> =A0 =A0 =A0 =A0 =A0$wand readblob $blob
> =A0 =A0 =A0 =A0 =A0return $wand
> =A0 =A0}
> =A0 =A0proc wand2Image { wand img } {
> =A0 =A0 =A0 =A0 =A0$img put [ $wand writeblob ]
> =A0 =A0}
> =A0 =A0proc resize { wand width height } {
> =A0 =A0 =A0 =A0 =A0$wand resize $width $height
> =A0 =A0}
> =A0 =A0proc getImage { path } {
> =A0 =A0 =A0 =A0 =A0set ret [image create photo]
> =A0 =A0 =A0 =A0 =A0$ret read $path
> =A0 =A0 =A0 =A0 =A0return $ret
> =A0 =A0}
> =A0 =A0proc putImage { img path } {
> =A0 =A0 =A0 =A0 =A0return [$img write $path]
> =A0 =A0}
> =A0 =A0proc putWand { wand path } {
> =A0 =A0 =A0 =A0 =A0return [$wand write $path]
> =A0 =A0}
>
> ... As for building tclMagick ... once you have a working version of
> ImageMagick, you can adapt the following script to build only the require=
d
> parts of tclMagick ... You don't need the entire autotools config/make to
> do so ...
>
> wnd=3D/usr/local/bin/Wand-config
> #CC=3Dmingw32-gcc
> CC=3Dgcc
> $CC -shared -DUSE_TCL_STUBS -fPIC -DUSE_TK_STUBS -DUSE_TK_STUBS -I. \
> =A0 =A0 =A0 =A0 =A0-I/usr/local/include -L/usr/local/lib -L/usr/lib \
> =A0 =A0 =A0 =A0 =A0`$wnd --ldflags --libs` \
> =A0 =A0 =A0 =A0 =A0-L /usr/local/lib -ltclstub8.5 \
> =A0 =A0 =A0 =A0 =A0-o tclmagick.so -O2 -DNDEBUG TclMagick.c
> # =A0 =A0 =A0 =A0-o tclmagick.so -O2 -DNDEBUG -Wl,-s TclMagick.c
>
> If you are on windows, you'll need MingW or CygWin ...
>
> HTH ...
> Cheers,
> Rob
> =A0 =A0 =A0 =A0---- Posted via Pronews.com - Premium Corporate Usenet New=
s Provider ----http://www.pronews.comoffers corporate packages that have ac=
cess to 100,000+ newsgroups

0
11/5/2008 5:43:37 PM
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.

I wrote a patch for TclMagick.  It's pretty good code, but I later created
my own solution for my needs.
 
> Any thoughts?

You could use megaimage and my JPEG and/or PNG extensions.  They are BSD
licensed, with the additional restrictions of the libjpeg and libpng
licenses.

They were actually used for the Tcl conference image feed last year, and I
think this year too.  Another extension I wrote to work with megaimage was
freetypeext (for compositing text over an image).

set buf [jpegext2:decode $jpegdata]
set mobj [megaimage $buf]
#For an image half the size use 500 500.  1000 is no change.
#1000 is used for better fixed point accuracy.
#There is also a scaleto for exact width and height.
$mobj scale 500 500 
set newjpegdata [jpegext2:encode [$mobj getdata]]
rename $mobj {}; #cleanup

If you need to convert a megaimage buffer to a Tk photo you can use
megaimagetk with [megaimage.to.photo].

This has some -DUSE_TCL_STUBS binaries I threw together quickly for an MJPEG
viewer before the conference this year:
http://whim.linuxsys.net/files/Tk_MJPEG_Win32_and_Linux-3.zip

The Win32 binaries in this case are newer than the Linux binaries in that
zip file.  They were all built for 8.5 I think.  I can provide updated 8.5
builds if you want for Linux and Win32, or instructions for building.  I
may even be able to provide MacOS X binaries as well.

The documentation is here: 
http://www.xmission.com/~georgeps/implementation/software/megapkg/megaimage.html
http://www.xmission.com/~georgeps/implementation/software/megapkg/megaimagetk.html
Tiffext is another encoder/decoder compatible with megaimage.
http://www.xmission.com/~georgeps/implementation/software/megapkg/tiffext.html

I'm hoping that eventually other Tcl developers will work with me on
the "Imagecore" ideas.  See: http://paste.tclers.tk/1323  Imagecore may
eventually supplant megaimage, and I'm hoping be in the Tcl core as an
optional package, though perhaps (for building and redistribution reasons)
not with the imagecore encoders/decoders that depend on other libraries.

--George
0
georgeps (404)
11/5/2008 5:53:09 PM
will@wjduquette.com schreef:
> 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.

You could also have a look at LRIPhoto (http://wfr.tcl.tk/1004 in 
french), its similar to http://wiki.tcl.tk/11924, but meant to work with 
critcl or odyce, so I would expect it to work on linux. I haven't tried 
it myself (except for clicking on it in the odyce demo on windows).

Peter
0
pwelten (22)
11/5/2008 6:32:24 PM
On Wed, 5 Nov 2008, MartinLemburg@Siemens-PLM wrote:
> Hi Rob,
>
> to extract the thumbnail from the EXIF data I used simply the tcllib
> jpeg package and stored the thumbnail into a file.

Probably a good approach!

>
> Ok - if the EXIF orientation tag tells, that the thumbnail should be
> rotated, than I used pixane to rotate the thumbnail before saving it.
>

Tricky, I find that the orientation varies from data source to data 
source, and can be misleading ...


> I also tried Image/TclMagick, but while building and using starpacks a
> lot I ran into problems with the DLL/registry dependencies on systems,
> where ImageMagick wasn't installed properly.
> Pixane worked right out of the (starpack) box. And it worked really
> quick!
>

Pixane is not BSD licensed, not available on a lot of platforms and source 
is not readily available.  No cigar.

> But I never needed Linux/Unix support, so I don't know about the Linux/
> Unix support of pixane.
>
> Best Regards,
>
> Martin

AFAIR, pixane has some licensing/source/platform availability issues which 
prevent my using them.  I use FreeBSD/OpenBSD/NetBSD/Ubuntu/Debian/Windoze 
and other OS'es ... so again, not helpful.

Admittedly, ImageMagick is a *BIG* but moving target, and the API is in 
flux, and tclMagick is unmaintained for all intents and purposes.

TclWand seems to have some potential, but has all the complexity of 
tclMagick (the big switch statement) as it is based upon tclMagick 0.45, 
and is available for Windoze only at the moment. Though, that might change 
if I can figure out the build process, and hand back a proper 
(non-windoze) build environment for it ... but I don't have time to do 
that just now ...

Here's a quick example of using of tclMagick to extract a thumbnail from 
an image, using the metadata contained within the corresponding wand ... 
and by getting the exif offsets and length, and then just pulling the 
string range out of the blob.  Pretty quick ...

   proc extractThumb { wand blob } {
         set off [wandProperty $wand exif:JPEGInterchangeFormat]
         if ![string length $off] {
                 return {}
         }
         set len [wandProperty $wand exif:JPEGInterchangeFormatLength]
         set chr [format "%s" \xd8]
         set ix [expr [string first $chr $blob $off] - 1 ]
         set lst [expr $ix + $len]
         return [string range $blob $ix $lst]
   }

Here's a small C code snippet to do the same (pull a thumbnail) using 
libexif, but I really can't recommend libexif in the absence of any 
reasonable documentation ... I seem to recall that it took me the better 
part of half a day to excavate enough info to write the code snippet 
below ... though it is fast!

/*
         this mechanism for extracting thumbnails uses libexif ...
*/
Blob_t  *im_ExtractThumb( Img_t *im ){

         ExifData *Exif ;
         Blob_t  *ret ;

         ret = (Blob_t *) NULL ;
         Exif = exif_data_new_from_data( im ->img ->buf, im ->img ->actual ) ;
         if( Exif ->size && Exif ->data ){
                 ret = copyBlob( Exif ->data, Exif ->size ) ;
         }
         exif_data_unref( Exif );
         return( ret ) ;
}

Ideally, a tcl extension based upon a simple library could be built which 
provides the image scaling/rotation/watermark capabilities, is portable, 
fast, and easily built on any platform ... but I'm not sure which library 
would be a sound starting point for such an extension.


Cheers,
Rob Sciuk
       ---- Posted via Pronews.com - Premium Corporate Usenet News Provider ----
http://www.pronews.com offers corporate packages that have access to 100,000+ newsgroups
0
Spam159 (460)
11/5/2008 10:22:05 PM
On Wed, 5 Nov 2008 17:22:05 -0500, Spam@ControlQ.com wrote:
> Admittedly, ImageMagick is a *BIG* but moving target, and the API is in 
> flux, and tclMagick is unmaintained for all intents and purposes.
> 
> TclWand seems to have some potential, but has all the complexity of 
> tclMagick (the big switch statement) as it is based upon tclMagick 0.45, 
> and is available for Windoze only at the moment. Though, that might change 
> if I can figure out the build process, and hand back a proper 
> (non-windoze) build environment for it ... but I don't have time to do 
> that just now ...

Rob:
I wrote the TclWand modification of the original TclMagick.
If you, or anyone, needs a TclWand built for a recent version of
ImageMagick I can make one available.
If you need help changing the build environment I can try to help with that
if/when you get around to it.

Pete
--
===============
NN=01
0
digipete (1)
11/6/2008 8:02:45 PM
On Wed, 5 Nov 2008 17:22:05 -0500, Spam@ControlQ.com wrote:> 
> Admittedly, ImageMagick is a *BIG* but moving target, and the API is in 
> flux, and tclMagick is unmaintained for all intents and purposes.
> 
> TclWand seems to have some potential, but has all the complexity of 
> tclMagick (the big switch statement) as it is based upon tclMagick 0.45, 
> and is available for Windoze only at the moment. Though, that might change 
> if I can figure out the build process, and hand back a proper 
> (non-windoze) build environment for it ... but I don't have time to do 
> that just now ...

Rob:
I wrote the TclWand modification of the original TclMagick. I've added the
ability to execute a command line directly from within TclWand. As a
trivial example, the commnad line "convert logo logo.png" would be:
magick convert logo: logo.png
The composite, mogrify and montage commands can also be called directly
like this.

If you, or anyone, needs a TclWand built for a recent version of
ImageMagick I can make one available.
If you need help changing the build environment I can try to help with that
if/when you get around to it.

Pete
-- 
NN=01
0
11/7/2008 2:25:58 PM
On Nov 5, 6:23=A0pm, w...@wjduquette.com wrote:
> On Nov 5, 8:52=A0am, 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. =A0Tk's native
> > > "$img copy -subsample" option yields poor results, and will only scal=
e
> > > images down, not up. =A0What other options are available?
>
> >http://wiki.tcl.tk/11924
> > is good code for me.
>
> That sounds just about perfect...if it works on Linux.

Hello, have a look at TkImageTools.

http://snackamp.sourceforge.net/releases/

-eric
0
eric1562 (1)
11/8/2008 9:37:29 AM
Reply:
Similar Artilces:

Percentage of coverage of an image
Hi all, for a customer of mine (a printing service) I wrote a little utility to calculate the percentage of coverage of an image, that is the number of not-white pixels respect to the total number of pixels (it is used for estimating big volume of black and white laser printings). Now I think to expand the features of this software by adding the calculation of the RGB and CYMK components of the image and I think to sell this tool as shareware with a quite low price (about 15 or 18 USD). Do you think that this tool at this price can be interesting for graphics services/freelance ? Thanks for y...

image operator and "streams"
Hello, I've mastered to use the image operator with strings. But how to do it with so called "streams"? And what are streams? Are they other files? Are they inside the document? Can they be both? I want to use stremas, because me was told in this group, that they provide arbitrary length data source for things like the image operator. So: what to do and how to use them? A small example please? Thanks in Advance, Oliver P.S.: My tool to extract an image out of ASCII-/PPM-files (looking for a bounding box) already works. But now I need to create ...

Delay between parent window resize/paint and child window resize
Hi, I'm working on making a splitter window system in pure win32. I have a main window with a child window, and when the main window resizes (I catch the WM_SIZE message in my main window wndproc) I call MoveWindow to resize the child window to maximize it's size within the parent. I have all the styles set like clipping children , etc so there isn't any flicker when the child resizes. I have the option checked to "show window contents while resizing/ dragging", and I on my slower laptop I notice if I grab the lower right hand corner of the main window and expan...

Image Inhancement (help me to understand this code)
iptcheckinput(inputImage,{'uint8','uint16','int16','single','double'}, {'nonsparse','2d'}, mfilename,'I',1); if nargin == 1 parameters = 5; membership = parameters(1)-abs(-parameters(1):parameters(1)); elseif nargin == 3 if strcmp(fuzzyMembershipType,'triangular') if ~(numel(parameters)==1) error('fcnBPDFHE supports only 1 parameter for Triangular Membership'); end membership = parameters(1)-abs(-parameters(1):parameters(1)); elseif strcmp(fuzzyMembers...

US-TX-Austin: Database Admin, Oracle 8i, Sybase 12.0, Perl scripting, HP-UX/SUN; (45331157605)
US-TX-Austin: Database Admin, Oracle 8i, Sybase 12.0, Perl scripting, HP-UX/SUN; (45331157605) ============================================================================================== Position: Database Admin Reference: SMC01799 Location: Austin TX Duration: 9M Skills: 5+yrs exp (within the past 7 years) with Oracle 8i and above supporting large production environments. 5+yrs exp supporting databases on Sun/HP-UX and NT platforms. 3+yrs exp experience (within the past 5 years) with Sybase ...

creative commons images tikz
Hello, I would like to publish my work with a creative commons licence, so I add the licence into the TeX document. Is there any Tikz image for the CC licence image? So my document should get a printable quality and the images should be rendered with Tikz. Does anybody have got an idea? Phil You can find some more information here: http://tex.stackexchange.com/questions/20308/creative-commons-logo and here: http://tex.stackexchange.com/questions/1725/how-do-i-generate-creative-commons-license-information On 2013-05-20 09:01:30 +0200, nignasi said: > You can...

Resize Flexgrid to SSTab Width After Form Resize
Hi, I have tried multiple things, to no avail. This what I need your assitance on. Originaly posted at: http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Controls/Q_22777606.html VB6 With WinXP 1 Form, 1 Listbox on left of form, 1 SSTab with 7 Tabs in one Row, 1 MSHflxgd in each Tab (total seven). The list box cover the entire left of the form. On the right side of list box is where I have SSTab. And within each SSTab I have 1 flexgrid control. Requirement : 1. Maximize the form at startup. 2. Resize the SSTab to fill up the form. (List box doesnt get resized. Stays on ...

how do I measure intensity difference between images of similar objects?
Hello All I am in the last stage of my project and I am kind of stuck on this little part. Let me explain my project, I have an instrument console with few glowing leds of different color. My intention here is to take the image of this console in a box, so that only the glowing leds are captured by the camera and the background looks black. After I have captured this image, I would like to know how could I find the "intensity" of the leds present and then compare these intensities with the another instrument console with similar leds placed, and so on. I dont really want to measure ...

ODBC causes Dolphin to crash or unable to save image
I tried doing this with a fresh image, too, but when I run this in a workspace (a few times): c := (DBConnection new) dsn: 'payment'; connect. rs := c query: 'select ssn, firstname, lastname, paidthrudate, [last paid date] as lastpaiddate from member'. rs size. c close. Dolphin will either crash or won't let me save the image. If it won't let me save the image, it gives me a debug. This is for a Paradox database, if that makes a difference. It seems a lot more stable if I don't include the line rs size. Any pointers here? Thanks! Jen Here&#...

Resizing a JLabel
Hi guys! There's a situation in my program that I want to resize a JLabel: I have a JDialog with a JPanel on it (with FlowLayout - it's one of the panels... not the only one). There's a JTextField, where the user can type a numeric code and after it, there's JLabel INITIALLY [height=3D0;width=3D0]. When the user types a valid code, I wanna retrieve the name of the person associated with it. That's simple and it's already done. I SELECT it from the database and mylabel.setText(myname). The JLabel shows it. BUT (here's the "but"!) if the name is longer tha...

Please help me with this script.
Hi, When I put the first javascript, it works fine. As soon as I put the second one, the effect stops on both and you can't see any pictures. This is the script I'm using. {How can I have this effect in 3 areas of the page?}What area of the script need to be change? Thank you for your help. =================================================================================================== <script language="JavaScript1.2" type="text/javascript"> var slideshow_width='140px' var slideshow_height='225px' var pause=3000 var fadeimages=new A...

image processing #146
i attached my coding reg to face detection process. clear all; close all; clc I=imread('face4.jpg'); imshow(I) cform = makecform('srgb2lab'); J = applycform(I,cform); figure;imshow(J); K=J(:,:,2); figure;imshow(K); L=graythresh(J(:,:,2)); BW1=im2bw(J(:,:,2),L); figure;imshow(BW1); M=graythresh(J(:,:,3)); figure;imshow(J(:,:,3)); BW2=im2bw(J(:,:,3),M); figure;imshow(BW2); O=BW1.*BW2; % Bounding box P=bwlabel(O,8); BB=regionprops(P,'Boundingbox'); BB1=struct2cell(BB); BB2=cell2mat(BB1); [s1 s2]=size(BB2); mx=0; for k=3:4:s2-1 p=BB2(1,k)*BB2(1,k+1); if p>mx &am...

Display larger size image
Hi All, I'm facing problem displaying image of size 5000X5000 .My window size is smaller than image size so i'm not able to see the complete image.i can use scroll bars to view the image but i need to rotate the image and the see the result everytime. For this my boss has given me suggestion to display only 20% of the image on window ,and rotation has to be applied to original copy. can someone explain me how to proceed with this problem. With regards, Deepa. Deepa wrote: > I'm facing problem displaying image of size 5000X5000 .My window size > is smaller...

image size
Hi all, Can you please help with this: I loaded an image and got 0 for its width and height: package require Img set image1 [image create photo -format bmp -file $fname] puts [$image1 configure -width],[$image1 configure -height] Result: -width {} {} 0 0,-height {} {} 0 0 Also, how can I make it smaller by, say, 1.5? Thanks iu2 wrote: > Hi all, > > Can you please help with this: > > I loaded an image and got 0 for its width and height: > > package require Img > set image1 [image create photo -format bmp -file $fname] > puts [$image1 configure -width],[$ima...

Dr. Dobb's Tcl-URL!
QOTW: "Then again, if you have people writing BIND config files that look like this, you have bigger problems than trying to parse them with Tcl." - sage Melissa Schrumpf, in a thread that provides excellent counsel on configuration from a Tcl perspective http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/1462b8dc8a16eec0/ "DoP: It seems unnecessary (and embarrassing) to memorialize such things in the ChangeLog. DKF: Instead, they get their own vanity thread on c.l.t..." POTW: GVI, The Graphical Voter Interface, is a GUI (Graphical User Interfa...

Resizing bitmaps
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. What is an easy way to resize, for example, a JPEG image using Ruby? Should be a way that can works both on GNU/Linux and Windows. Thanks! - -- - ---------------------------- Eust=E1quio "TaQ" Rangel eustaquiorangel@yahoo.com http://beam.to/taq Usu=E1rio GNU/Linux no. 224050 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.7 (GNU/Linux) iD8DBQFC8oFNb6UiZnhJiLsRAuRyAJ91ebNvqOiQ7fUM04iA/nDtHN6bgwCeImjE WzVmNmgfcRIa1bKpERFY1Jg=3D =3DnuJ+ -----END PGP SIGNATURE----- On 8/4/05, Eustaquio Rangel de Oliveira Jr. <eustaquiorangel@y...

Window resize problem (WINAPI) #2
Hi, i have problem with resizing windows. I have a main window, which contains TabControl and static at the bottom. There are more one edit control and list view which are shown in TabControl, when user selecte proper tab. In my window proce i do something like that: case WM_SIZE: HDWP hdwp; RECT rc; SetRect(&rc, 0, 0, LOWORD(lParam) - 2*PADD, HIWORD(lParam) - 2*PADD - BPADD); TabCtrl_AdjustRect(tabs, FALSE, &rc); hdwp = BeginDeferWindowPos(4); DeferWindowPos(hdwp, tabs, NULL, PADD, PADD, LOWORD(lParam) - 2*PADD, ...

How to make jpg image tranparent?
I had a copy of PSP over 10 years ago and it was easy to overlay a transparent image over another....really intuitive. I've spent the last 2 hours trying to do the same thing without success......Am I just getting old, or is the software more (too) complex? TIA Nick nickc wrote: > I had a copy of PSP over 10 years ago and it was easy to > overlay a transparent image over another....really > intuitive. I've spent the last 2 hours trying to do the > same thing without success......Am I just getting old, or > is the software more (too) complex? First, there is no ...

Resize figure
Hi all I have a figure that displayd same plot. The displayed data is very big and the plot drawing thaks time ( 1-1.5 sec). My problem accurs when i'm try to resize the figure, its took very long time. What shuld i do to make the resize faster? which propery should accelerate the resize action. Best regards , Leon You could set the size of your figure so it doesn't draw it big in the first place by setting the 'Position' property of the figure. width = 400; height = 350; figure('Position', [300 200 width height]); If you need to be able to resize the figure then ...

Resizable drawers and sheets?
Is it possible for you to set drawers and sheets to resize in RB? Seems most of mine are stuck in static positions, when some could definitely benefit from resizing and moving. Checking 'LiveResize' and various zoom functions haven't helped. :\ Any ideas? - Nick > Is it possible for you to set drawers and sheets to resize in RB? > Seems most of mine are stuck in static positions, when some could > definitely benefit from resizing and moving. Checking 'LiveResize' > and various zoom functions haven't helped. :\ Any ideas? Nope.. It's ...

How to do the subpixel shift for of an original image multiple times with different values for each time.
Doubt: How to do the subpixel shift for of an original image multiple times with different values for each time. Background: Lets say i have a gray image of 256x256 (called LR image), and i want to create a super-resolution of this LR image to 512x512 (called HR image). As, in most of the super resolution algorithm, we try to generate multiple LR image with multiple xshift and yshift values which happens to be the subpixel values (<1). Now using these multiple LRs, we try to get the HR using some kind of interpolation methods. I am looking to do the xshift and yshift, say (0.5, 0.25)...

Tcl Calling C Program via Serial Line
I have a Tcl/Tk GUI on a laptop. I have a linux box with no keyboard or monitor. The code below allows me to connect to the linux box using a serial line. When the user clicks one of the GUI buttons, the following command line is sent to the linux box, which invokes the recordData program: "recordData Transmit 2" That works great! The problem is that recordData, which is a C program, returns a status value. When I attempt to get the status back, all I get is the "recordData Transmit 2" that was sent out. My attempt to get the status value back is in "proc Reader{}&q...

Resizing image control with jpg image
Using A2K I have an image control on a report and use code to set the image.picture to the required jpg. 3 of the jpgs resize properly but 2 do not - they display much smaller than the image control. The problem jpgs were originally created as line drawings in Word. They were then copy and pasted to Paint where they were saved as jpg files. Sizemode is set to stretch.(have tried clip and zoom but no better). I cannot find any way to make them expand to the size of the image control. Here is a previous post of mine on this subject. If you did a search on GoogleGroups you would find a l...

Expect scripting
Hello, I have run into a problem where the [gets $filename line] cmd is not giving me back the file name, but is giving back file#, where # is an incrementing number. Two questions: Why does this happen? What am I doing wrong? Below is the code and the version information: ######################################################### proc getcmdfile equipcmds { # grabs the file path and name, sets the equip var from the var sent to the subproc and sets the counter. set cmdFile [open "/home/ke010596/$equipcmds\cmdfile.txt"] send "\n$cmdFile\n" return $cmdFile } ######...

File references or embedded images for storing faxes?
Hi all- We would like to expand the functionality of our FileMaker invoicing system to allow us to store the faxed order confirmations of our vendors. My question: would it make sense to store these as images in a container field in each order, or is it necessary to store just the reference to avoid bloating the database? The files in question are about 15kb each, so it seems to me it wouldn't be too much of a burden to store them directly, but am I setting myself up for problems down the road? Also, since our users access the database over a network, they would need to all be able to &quo...