From: Gerhard Reithofer on
On Thu, 8 Jul 2010, Gerhard Reithofer wrote:

> On Wed, 7 Jul 2010, Andreas Leitgeb wrote:
>
> > Gerhard Reithofer <gerhard.reitho...(a)tech-edv.co.at> wrote:
> > > $ tclsh
> > > % package require tablelist
> > > ;;; ### One blank line here
> > > % proc unknown args { puts "Unknown: $args" }

....

> Bingo - Mr. Sherlock Holmes ;-)
>
> $ tclsh
> % catch {package require tablelist} msg
> 1
> % puts ">>>$msg<<<"
> >>><<<
> % set errorInfo
>
> while executing
> "image create photo tablelist_gtk_collapsedImg -data "
> iVBORw0KGgoAAAANSUhEUgAAABIAAAAOCAYAAAAi2ky3AAAABGdBTUEAALGPC/xhBQAAABl0RVh0
> U29mdHdhcmUAUGFpbnQ..."
> (procedure "gtkTreeImgs" line 8)
> invoked from within

Yes, my PNG Image extension 1.4 seems to be broken.

It fails when using -data option, the error management seems to be
broken too.

========================================================
$ tclsh
% package require Tk
8.5.8
% package require img::png
1.4
% set imgdata(png) "\
iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\
AAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFkSURB\
VCiRnY4/S1thGMV/z3vfXJNGUjs4SCgWweigxhauQaRFYhEEoYiLg5MgLiLo5tB+gw79EJ3chH6A\
+Ae9Ri0p0q0UF7GICjai3uQ+r0sIgrh44Ezn/A5HnHMA5IPCu9akXVXn3qu677c1/VophyfDH0a/\
3EXRZxo9AJtInNoG1NaSMBuzxWyq/03GrO+eLm79vhgDBj1rB5YX5u34x2ITnPg03WEAPCNzQ7k2\
Mz3SYXLZNCtTXb4R6c4HhbcA1nr4vt80gAUQ4UXS95qLIoJvjQJJnNPS5rb29vSYKIrYPzhEVY3N\
B4XXwMHm0bkEuZf0dWZYD//pTRRfAu5/tfptJ9xr+Vn5NWlEzupxvOac25GBYPgcIYODlC9eVIvF\
84xGMYoDRP6g9YXWdHqpen09WymHN42rmknkZqyk2omBxmHjg9GrY+p/f7yqlMMSUOKBDM/Us0EL\
QFyD+O5xqrUnwXsC0n5niE5C8QAAAABJRU5ErkJggg=="
.... ; # image data displayed
% set res [catch {image create photo pngimg -data $imgdata(png)} result]
1
% puts "result: $result\nerrorCode: $errorCode\nerrorInfo: $errorInfo"
result:
errorCode: NONE
errorInfo:
while executing
"image create photo pngimg -data $imgdata(png)"
% pack [label .l -image pngimg]
image "pngimg" doesn't exist
========================================================

If calling just "image create photo pngimg -data $imgdata(png)" or
"image create photo -data $imgdata(png)" nothing is returned (as
described earlier) and no error message appears, but no image "pngimg"
is created.
....
% image create photo -data $imgdata(png) ; ### NOTHING returend!
% puts "errorInfo: $errorInfo"
errorInfo:
while executing
"image create photo pngimg -data $imgdata(png)"
% pack [label .l -image pngimg]
image "pngimg" doesn't exist
....

The same script works with -file $imgfile, but nothing is diplayed on
the button (which also shouldn'd be, but did not investigate in detail).

The same script works with other image formats (require Img, img::bmp,
etc.) displaying the images correct.

Can anyone reproduce this?

--
Gerhard Reithofer
Tech-EDV Support Forum - http://support.tech-edv.co.at
From: Donal K. Fellows on
On 08/07/2010 09:47, Gerhard Reithofer wrote:
> Yes, my PNG Image extension 1.4 seems to be broken.

I know this isn't helpful to you, but... it works with the HEAD of Tk. :-)

> It fails when using -data option, the error management seems to be
> broken too.

The thing to check for is whether you're handling sBIT, pHYs and tEXt
sections correctly (by ignoring them). If you're in the area, you might
as well also make sure that you handle multiple IDAT sections correctly;
some images are like that.

Donal.
From: Paul on
Hi Gerhard,

I've checked your test script with ActiveState Tcl 8.5.8 on Win XP
32-bit, SuSE (32-bit and 64-bit) and it worked on all platforms.

Must be something with your setup.

Paul

On 08.07.2010 10:47, Gerhard Reithofer wrote:
> On Thu, 8 Jul 2010, Gerhard Reithofer wrote:
>
>> On Wed, 7 Jul 2010, Andreas Leitgeb wrote:
>>
>>> Gerhard Reithofer<gerhard.reitho...(a)tech-edv.co.at> wrote:
>>>> $ tclsh
>>>> % package require tablelist
>>>> ;;; ### One blank line here
>>>> % proc unknown args { puts "Unknown: $args" }
>
> ...
>
>> Bingo - Mr. Sherlock Holmes ;-)
>>
>> $ tclsh
>> % catch {package require tablelist} msg
>> 1
>> % puts ">>>$msg<<<"
>>>>> <<<
>> % set errorInfo
>>
>> while executing
>> "image create photo tablelist_gtk_collapsedImg -data"
>> iVBORw0KGgoAAAANSUhEUgAAABIAAAAOCAYAAAAi2ky3AAAABGdBTUEAALGPC/xhBQAAABl0RVh0
>> U29mdHdhcmUAUGFpbnQ..."
>> (procedure "gtkTreeImgs" line 8)
>> invoked from within
>
> Yes, my PNG Image extension 1.4 seems to be broken.
>
> It fails when using -data option, the error management seems to be
> broken too.
>
> ========================================================
> $ tclsh
> % package require Tk
> 8.5.8
> % package require img::png
> 1.4
> % set imgdata(png) "\
> iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\
> AAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFkSURB\
> VCiRnY4/S1thGMV/z3vfXJNGUjs4SCgWweigxhauQaRFYhEEoYiLg5MgLiLo5tB+gw79EJ3chH6A\
> +Ae9Ri0p0q0UF7GICjai3uQ+r0sIgrh44Ezn/A5HnHMA5IPCu9akXVXn3qu677c1/VophyfDH0a/\
> 3EXRZxo9AJtInNoG1NaSMBuzxWyq/03GrO+eLm79vhgDBj1rB5YX5u34x2ITnPg03WEAPCNzQ7k2\
> Mz3SYXLZNCtTXb4R6c4HhbcA1nr4vt80gAUQ4UXS95qLIoJvjQJJnNPS5rb29vSYKIrYPzhEVY3N\
> B4XXwMHm0bkEuZf0dWZYD//pTRRfAu5/tfptJ9xr+Vn5NWlEzupxvOac25GBYPgcIYODlC9eVIvF\
> 84xGMYoDRP6g9YXWdHqpen09WymHN42rmknkZqyk2omBxmHjg9GrY+p/f7yqlMMSUOKBDM/Us0EL\
> QFyD+O5xqrUnwXsC0n5niE5C8QAAAABJRU5ErkJggg=="
> ... ; # image data displayed
> % set res [catch {image create photo pngimg -data $imgdata(png)} result]
> 1
> % puts "result: $result\nerrorCode: $errorCode\nerrorInfo: $errorInfo"
> result:
> errorCode: NONE
> errorInfo:
> while executing
> "image create photo pngimg -data $imgdata(png)"
> % pack [label .l -image pngimg]
> image "pngimg" doesn't exist
> ========================================================
>
> If calling just "image create photo pngimg -data $imgdata(png)" or
> "image create photo -data $imgdata(png)" nothing is returned (as
> described earlier) and no error message appears, but no image "pngimg"
> is created.
> ...
> % image create photo -data $imgdata(png) ; ### NOTHING returend!
> % puts "errorInfo: $errorInfo"
> errorInfo:
> while executing
> "image create photo pngimg -data $imgdata(png)"
> % pack [label .l -image pngimg]
> image "pngimg" doesn't exist
> ...
>
> The same script works with -file $imgfile, but nothing is diplayed on
> the button (which also shouldn'd be, but did not investigate in detail).
>
> The same script works with other image formats (require Img, img::bmp,
> etc.) displaying the images correct.
>
> Can anyone reproduce this?
>
From: Gerhard Reithofer on
Hi Paul,

On Thu, 8 Jul 2010, Paul(a)Tcl3D wrote:
> Hi Gerhard,
>
> I've checked your test script with ActiveState Tcl 8.5.8 on Win XP 32-bit,
> SuSE (32-bit and 64-bit) and it worked on all platforms.
>
> Must be something with your setup.
>
> Paul
>
> On 08.07.2010 10:47, Gerhard Reithofer wrote:
> > On Thu, 8 Jul 2010, Gerhard Reithofer wrote:
> > > On Wed, 7 Jul 2010, Andreas Leitgeb wrote:

....

thank for your test, but now I have found a new situation which makes
me think, that ActiveTcl IS the problem.

I made the same test on another machine - this has Tcl 8.5.7:

# tclsh test.tcl
Tcl/Tk 8.5.7
img::png 1.4
result: pngimg
errorCode: POSIX ENOENT {no such file or directory}
errorInfo: couldn't open "/net/dev/TCL/StdTools/tclIndex": no such file
or directory
while executing
"open [file join $dir tclIndex]"


It WORKED - see above the line "result: pngimg", the image name was
returned from [image create] in the [catch] command and it was
displayed.
The errorCode is from a previous internal lookup, I think and has
nothing to do with the test.

After then I did a
teacup udate
which updated many packages.
# Installed 50 newer packages
# Installed 239 unknown packages

A new run of the SAME script on the SAME machine now results in:

# tclsh test.tcl
Tcl/Tk 8.5.7
img::png 1.4
result:
errorCode: NONE
errorInfo:
while executing
"image create photo pngimg -data $imgdata(png)"
image "pngimg" doesn't exist
while executing
"label .l -image pngimg"
invoked from within
"pack [label .l -image pngimg]"
(file "test.tcl" line 16)

Here AGAIN the [image create] command does not return a value!
Both outputs are from the same shell window.

This is Tcl 8.5.7, on my other test machine (where all my earlier tests
were done) 8.5.8 is installed, both are 64-bit Linux (Debian Lenny -
this test and new Ubuntu - prior tests).
On both machines img::png 1.4 is installed, identical file
libtkimgpng1.4.so on both machines due to md5sum.

So img::png (at least the library) is out of suspicion and it has not to
do with the Tcl version (8.5.7 <-> 8.5.8).
No change has been made to my machine beteween the 2 tests.

I've saved the Console history in a text file, therefore it is traceable
which modules have been installed (but it's just a large list with
almost 300 modules) and I saved the "buggy???" ActiveTcl directory, if
someone is interested in analyzing it.

Finally, here's my test script:

##################################################
puts "Tcl/Tk [package require Tk]"
puts "img::png [package require img::png]"

set imgdata(png) "iVBORw0KGgoAAAANSUhEUgAAAA4AAAAKCAYAAACE2W/HAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\
AAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFkSURB\
VCiRnY4/S1thGMV/z3vfXJNGUjs4SCgWweigxhauQaRFYhEEoYiLg5MgLiLo5tB+gw79EJ3chH6A\
+Ae9Ri0p0q0UF7GICjai3uQ+r0sIgrh44Ezn/A5HnHMA5IPCu9akXVXn3qu677c1/VophyfDH0a/\
3EXRZxo9AJtInNoG1NaSMBuzxWyq/03GrO+eLm79vhgDBj1rB5YX5u34x2ITnPg03WEAPCNzQ7k2\
Mz3SYXLZNCtTXb4R6c4HhbcA1nr4vt80gAUQ4UXS95qLIoJvjQJJnNPS5rb29vSYKIrYPzhEVY3N\
B4XXwMHm0bkEuZf0dWZYD//pTRRfAu5/tfptJ9xr+Vn5NWlEzupxvOac25GBYPgcIYODlC9eVIvF\
84xGMYoDRP6g9YXWdHqpen09WymHN42rmknkZqyk2omBxmHjg9GrY+p/f7yqlMMSUOKBDM/Us0EL\
QFyD+O5xqrUnwXsC0n5niE5C8QAAAABJRU5ErkJggg=="

set res [catch {image create photo pngimg -data $imgdata(png)} result]
puts "result: $result\nerrorCode: $errorCode\nerrorInfo: $errorInfo"
pack [label .l -image pngimg]
##################################################

Unfortunately this script doesn't display the [catch] result $res, but
I'm rather sure, that it was 0 in working version and it is definitely 1
in failing version now.

Any more ideas?

BTW: I now will delete and reinstall my Tcl-Distro on the former test
machine.

--
Gerhard Reithofer
Tech-EDV Support Forum - http://support.tech-edv.co.at
From: Larry W. Virden on
Okay, so I ran your test script against 2 different versions of Tcl
that I have installed here. One version I built from source - the
other version is from ActiveTcl. Here's what I see:

srv45 (5700) $ /my/build/tclsh8.5 /tmp/.lwv/t.tk
Tcl/Tk 8.5.4
img::png 1.3
result: Read Error
errorCode: NONE
errorInfo: Read Error
while executing
"image create photo pngimg -data $png"
res: 1
image "pngimg" doesn't exist
while executing
"label .l -image pngimg"
invoked from within
"pack [label .l -image pngimg] "
(file "/tmp/.lwv/t.tk" line 20)
srv45 (5701) $ which tclsh8.5
/usr/tcl85/bin/tclsh8.5
srv45 (5702) $ fndall tclsh8.5
/usr/tcl85/bin/tclsh8.5
/vol/tclsrcsol/ActiveTcl-8.5.4/bin/tclsh8.5
/vol/tclsrcsol/ActiveTcl/bin/tclsh8.5
srv45 (5703) $ /vol/tclsrcsol/ActiveTcl/bin/tclsh8.5 /tmp/.lwv/t.tk
Tcl/Tk 8.5.4
img::png 1.4
result: Read Error
errorCode: NONE
errorInfo: Read Error
while executing
"image create photo pngimg -data $png"
res: 1
image "pngimg" doesn't exist
while executing
"label .l -image pngimg"
invoked from within
"pack [label .l -image pngimg] "
(file "/tmp/.lwv/t.tk" line 20)


Several things to observe:

1. Two different versions of img:png - and both have the same error.
2. I get a little different output than you - my errorInfo says "Read
Error"
3. I slightly modified your script so that it output $res and it used
a scalar variable rather than an array variable. I got the same
results regardless of using a scalar or array - just wanted to be
certain there wasn't some issue there.
4. Most importantly, I see the error even when not using ActiveTcl. I
can't explain your environment - but the problem looks like either a
bug in image, or a bug in the png data you provide.

Now, here's what I did next. I went over to libpng.org, went to
http://www.libpng.org/pub/png/pngsuite.html and saved the first png
icon on the page. I then modified your test script to say

set pngfile /path/to/basn16a16.png
set res [catch {image create photo pngimg -file $pngfile} result]

and then ran the script. I get this out when I use either the self
built or the ActiveTcl tclsh:
Tcl/Tk 8.5.4
img::png 1.4
result: pngimg
errorCode: NONE
errorInfo: invalid command name "tk::pkgconfig"
while executing
"tk::pkgconfig get fontsystem"
res: 0

as well as a Tk displayed widget containing the icon.
Note that there is no pkgconfig listed in the script that you provided
and that I tweaked.