For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > March 2005 > Bug in module Tk-JPEG?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Bug in module Tk-JPEG?
Graham

2005-03-06, 3:57 pm

I'm OK in Perl but a Perl/Tk newbie. I've recently installed the Tk-JPEG
module for Win32 from the ActiveState PPM2 Repository. When I run my
application and it attempts to load a JPEG image, I get the error message
'couldn't recognise data in image file "[five strange characters]" at
C:/Perl/site/lib/Tk.Image.pm line 21. This line reads
my $obj = $widget->Tk::image('create',$leaf,@_);

The program works fine when loading a GIF image (the GIF image loader is
part of the base Perl/Tk distribution). I am running Tk v800.024 on W32. Any
ideas if there's a bug in this Tk-JPEG module?


Graham

2005-03-06, 3:57 pm

PS - I'm running Perl 5.6.1

"Graham" <graham@letsgouk.com> wrote in message news:422b02a7.0@entanet...
> I'm OK in Perl but a Perl/Tk newbie. I've recently installed the Tk-JPEG
> module for Win32 from the ActiveState PPM2 Repository. When I run my
> application and it attempts to load a JPEG image, I get the error message
> 'couldn't recognise data in image file "[five strange characters]" at
> C:/Perl/site/lib/Tk.Image.pm line 21. This line reads
> my $obj = $widget->Tk::image('create',$leaf,@_);
>
> The program works fine when loading a GIF image (the GIF image loader is
> part of the base Perl/Tk distribution). I am running Tk v800.024 on W32.
> Any ideas if there's a bug in this Tk-JPEG module?
>
>



Jack D

2005-03-07, 4:03 pm

Did you "use Tk::JPEG"?

Jack
PS..any sample code?

"Graham" <graham@letsgouk.com> wrote in message news:422b02a7.0@entanet...
> I'm OK in Perl but a Perl/Tk newbie. I've recently installed the Tk-JPEG
> module for Win32 from the ActiveState PPM2 Repository. When I run my
> application and it attempts to load a JPEG image, I get the error message
> 'couldn't recognise data in image file "[five strange characters]" at
> C:/Perl/site/lib/Tk.Image.pm line 21. This line reads
> my $obj = $widget->Tk::image('create',$leaf,@_);
>
> The program works fine when loading a GIF image (the GIF image loader is
> part of the base Perl/Tk distribution). I am running Tk v800.024 on W32.

Any
> ideas if there's a bug in this Tk-JPEG module?
>
>



Graham

2005-03-07, 8:58 pm

No, I didn't (silly me).

Added "use Tk::JPEG", but got the following error message.....
"Tk:JPEG object version 800.023 does not mach $Tk::JPEG::XS_VERSION 800.024
at C:/Perl/lib/Dynaloader.pm line 225
Compliation failed in require at program.pl line 4 [the "use Tk::JPEG" line]
BEGIN failed--compilation aborted at program.pl line 4

Presumably this is caused by a mismatch between the Tk-JPEG module
(800.023?) and my version of Tk (800.024) ??

The following us a slimmed down (and non fully working) example of my code

#!/usr/local/bin/perl -w

use strict;

use Tk;

use Tk::JPEG; # thanks to Jack D for this line!

# still need to inport other image loaders!

$mw = MainWindow->new;

$mw->title("Working Title");

$mw->withdraw;

my $imagepath = $mw->getOpenFile(-title => "Select Image");

my $numchars = length($imagepath);

my $extension = substr($imagepath, ($numchars-3), 3);

my $tl = $mw->Toplevel();

$tl->title("Working Title");

if ((my $extension =~ /gif/i)or($extension =~ /jpg/i)or($extension =~
/png/i)or($extension =~ /tif/i)or($extension =~ /bmp/i)or($extension =~
/ppm/i)) {

my $imagefile = $tl->Photo(-file => "$imagepath");

my $width = $imagefile->width;

my $height = $imagefile->height;

if (($width < 200)&&($height < 200)) {

# toplevel wigets packed here if loadable, small image selected

}

else {

# toplevel 'error stuff' wigets packed here if image selected is too large

}

else {

# toplevel 'different error stuff' wigets packed here if file selected is
not a loadable image

}

Mainloop;

# processing of selected small image commences here



"Jack D" <goodcall1@hotmail.dot.com> wrote in message
news:k1RWd.17405$fc4.11689@edtnps89...
> Did you "use Tk::JPEG"?
>
> Jack
> PS..any sample code?
>
> "Graham" <graham@letsgouk.com> wrote in message news:422b02a7.0@entanet...
> Any
>
>



Jack D

2005-03-08, 8:59 pm

"Graham" <graham@letsgouk.com> wrote in message news:422cb1fe.0@entanet...
> No, I didn't (silly me).
>
> Added "use Tk::JPEG", but got the following error message.....
> "Tk:JPEG object version 800.023 does not mach $Tk::JPEG::XS_VERSION

800.024
> at C:/Perl/lib/Dynaloader.pm line 225
> Compliation failed in require at program.pl line 4 [the "use Tk::JPEG"

line]
> BEGIN failed--compilation aborted at program.pl line 4
>
> Presumably this is caused by a mismatch between the Tk-JPEG module
> (800.023?) and my version of Tk (800.024) ??


Try the following hack - of course you would substitute an 800.024 for the
800.022 in the suggestion.

http://aspn.activestate.com/ASPN/Mail/Message/1010964

Jack


Jack D

2005-03-08, 8:59 pm

Oops - I meant substitute 800.023 ...

"Jack D" <goodcall1@hotmail.dot.com> wrote in message
news:x7pXd.10328$i6.3651@edtnps90...
> "Graham" <graham@letsgouk.com> wrote in message news:422cb1fe.0@entanet...
> 800.024
> line]
>
> Try the following hack - of course you would substitute an 800.024 for the
> 800.022 in the suggestion.
>
> http://aspn.activestate.com/ASPN/Mail/Message/1010964
>
> Jack
>
>



Graham

2005-03-09, 8:57 pm

Unfortunately I get a similar error when I try this hack substituting
800.023 for 800.022 ....

"Tk:JPEG object version 800.023 does not match $Tk::JPEG::XS_VERSION 19 at
C:/Perl/lib/Dynaloader.pm line 225
Compliation failed in require at program.pl line 4 [the "use Tk::JPEG" line]
BEGIN failed--compilation aborted at program.pl line 4"

If I substitute 800.024 for 800.022, I get the same error but with VERSION
20 rather than VERSION 19.

Not sure where I go from here

"Jack D" <goodcall1@hotmail.dot.com> wrote in message
news:L5qXd.21845$fc4.10796@edtnps89...
> Oops - I meant substitute 800.023 ...
>
> "Jack D" <goodcall1@hotmail.dot.com> wrote in message
> news:x7pXd.10328$i6.3651@edtnps90...
>
>



Jack D

2005-03-09, 8:57 pm

"Graham" <graham@letsgouk.com> wrote in message news:422f7329.0@entanet...
> Unfortunately I get a similar error when I try this hack substituting
> 800.023 for 800.022 ....
>
> "Tk:JPEG object version 800.023 does not match $Tk::JPEG::XS_VERSION 19 at
> C:/Perl/lib/Dynaloader.pm line 225
> Compliation failed in require at program.pl line 4 [the "use Tk::JPEG"

line]
> BEGIN failed--compilation aborted at program.pl line 4"
>
> If I substitute 800.024 for 800.022, I get the same error but with VERSION
> 20 rather than VERSION 19.
>
> Not sure where I go from here


See here for a similar problem with no solution:
http://aspn.activestate.com/ASPN/Ma...2-users/1322025

Two options I guess?

1. Upgrade to a newer perl and Tk.
http://activestate.com/Products/Dow...x?id=ActivePerl

2. Compile it yourself to match your current Tk version. You will need
Microsoft Visual C++.

The third option has already been tried (i.e. ask activestate to do #2 for
you) but v800.024 isn't really supported anymore - right?

Jack


Graham

2005-03-11, 3:58 am

Took Jack D's option 1
Uninstalled Tk 800.024, then upgraded from Perl 5.6.1 build 638 to Perl
5.8.6 build 811 which seems to come complete with Tk 804.027
Ran my script and got a similar (but not identical) error message to
previously
Thought to myself, 'as I've got a new Perl and a new Tk, I probably need a
newer Tk-JPEG', so uninstalled my old one, but when I tried to re-install it
using ppm3, I got an 'Error: No suitable installation target found for
package Tk-JPEG'
Also, when using ppm3 to describe it, I get an 'Error: PPD for 'Tk-JPEG.ppd'
could not be found. Am using the standard ActiveState repository
So by ungrading to a new perl and a new Tk, I've actually gone backwards!!
Life's a XXXXX, ain't it?

"Jack D" <goodcall1@hotmail.dot.com> wrote in message
news:LSLXd.10860$ZO2.4600@edtnps84...
> "Graham" <graham@letsgouk.com> wrote in message news:422f7329.0@entanet...
> line]
>
> See here for a similar problem with no solution:
> http://aspn.activestate.com/ASPN/Ma...2-users/1322025
>
> Two options I guess?
>
> 1. Upgrade to a newer perl and Tk.
> http://activestate.com/Products/Dow...x?id=ActivePerl
>
> 2. Compile it yourself to match your current Tk version. You will need
> Microsoft Visual C++.
>
> The third option has already been tried (i.e. ask activestate to do #2 for
> you) but v800.024 isn't really supported anymore - right?
>
> Jack
>
>



Jack D

2005-03-11, 3:58 am

"Graham" <graham@letsgouk.com> wrote in message news:4230bb1f.0@entanet...
> Took Jack D's option 1
> Uninstalled Tk 800.024, then upgraded from Perl 5.6.1 build 638 to Perl
> 5.8.6 build 811 which seems to come complete with Tk 804.027
> Ran my script and got a similar (but not identical) error message to
> previously
> Thought to myself, 'as I've got a new Perl and a new Tk, I probably need a
> newer Tk-JPEG', so uninstalled my old one, but when I tried to re-install

it
> using ppm3, I got an 'Error: No suitable installation target found for
> package Tk-JPEG'
> Also, when using ppm3 to describe it, I get an 'Error: PPD for

'Tk-JPEG.ppd'
> could not be found. Am using the standard ActiveState repository
> So by ungrading to a new perl and a new Tk, I've actually gone backwards!!
> Life's a XXXXX, ain't it?


Try this:

ppm install http://theoryx5.uwinnipeg.ca/ppms/Tk-JPEG.ppd

Hopefully this was built against the newest Tk. If not - send Randy Kobes a
nicely worded e-mail asking for a new ppm.

Jack


Graham

2005-03-11, 8:57 am


"Jack D" <goodcall1@hotmail.dot.com> wrote in message
news:ko5Yd.33730$fc4.7192@edtnps89...
> "Graham" <graham@letsgouk.com> wrote in message news:4230bb1f.0@entanet...
> it
> 'Tk-JPEG.ppd'
>
> Try this:
>
> ppm install http://theoryx5.uwinnipeg.ca/ppms/Tk-JPEG.ppd
>
> Hopefully this was built against the newest Tk. If not - send Randy Kobes
> a
> nicely worded e-mail asking for a new ppm.
>
> Jack
>
>

When I tried Jack's suggestion, I got "Successfully installed Tk-JPEG
version 2.014 in ActivePerl 5.6.1.638", which is interesting as this is my
old Perl - I've now upgraded to 5.8.6 build 811".
Running my script I now get a screen full of error stuff, generally along
the lines of "Couldn't recongnise data in Image file "[data]" at "[file]"
Jack - I presume you meant asking Randy Kobes for a new ppd (not a ppm), but
I guess the ppd is OK as the package has installed.
Must admit I'm by the reference to my old perl. What to do? Any
ideas, Jack?


Steve Lidie

2005-03-11, 3:58 pm

Graham <graham@letsgouk.com> wrote:

> Running my script I now get a screen full of error stuff, generally along
> the lines of "Couldn't recongnise data in Image file "[data]" at "[file]"


Did you specify -format => 'jpeg' ????
Jack D

2005-03-15, 4:02 am

Graham - Did you get this working yet? (after Steve's comment?)

"Graham" <graham@letsgouk.com> wrote in message news:42315198.0@entanet...
>
> "Jack D" <goodcall1@hotmail.dot.com> wrote in message
> news:ko5Yd.33730$fc4.7192@edtnps89...
news:4230bb1f.0@entanet...[color=darkred]
need[color=darkred]
re-install[color=darkred]
Kobes[color=darkred]
> When I tried Jack's suggestion, I got "Successfully installed Tk-JPEG
> version 2.014 in ActivePerl 5.6.1.638", which is interesting as this is my
> old Perl - I've now upgraded to 5.8.6 build 811".
> Running my script I now get a screen full of error stuff, generally along
> the lines of "Couldn't recongnise data in Image file "[data]" at "[file]"
> Jack - I presume you meant asking Randy Kobes for a new ppd (not a ppm),

but
> I guess the ppd is OK as the package has installed.
> Must admit I'm by the reference to my old perl. What to do? Any
> ideas, Jack?
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com