skleblan has asked for the wisdom of the Perl Monks concerning the following question:
I’m experimenting around with Tk using StrawberryPerl, and I’m practicing/experimenting with displaying images. For some reason, I can use Tk::Photo to load and display GIF’s, but I can’t seem to get it to work with JPG’s or PNG’s. I’m sure that there are probably other modules available. I wouldn’t mind experimenting with them too. However, I’m trying to give Tk a thorough trial before I jump ship for something else.
use strict; use warnings; use Tk; my $mw = MainWindow->new; my $lbl = $mw->Label; my $photo = $mw->Photo(-file=>”samplejpg1.jpg”); $lbl->configure(-image=>$photo); $lbl->pack; MainLoop;
If I let Tk try to auto detect the type, then I get couldn’t recognize data in image file “samplejpg1.jpg” at C:/Strawberry/Perl/site/lib/Tk/Image.pm line 21. If I specify a format, using -format=>”jpg” then I get image file format “jpg” is not supported at C:/Strawberry/Perl/site/lib/Tk/Image.pm line 21.
Same thing happens when I switch out the JPEG for the PNG file. But if I swap out the file for a GIF, then it displays as expected. I suppose it’s possible that I have bad test images, but I’m not sure that is likely. Aren’t these pretty standard/stable image types?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Displaying PNG and JPG images using Tk on Windows
by pryrt (Abbot) on May 13, 2019 at 19:35 UTC | |
by skleblan (Sexton) on May 13, 2019 at 20:09 UTC | |
|
Re: Displaying PNG and JPG images using Tk on Windows
by Discipulus (Canon) on May 13, 2019 at 20:14 UTC | |
by skleblan (Sexton) on May 16, 2019 at 18:06 UTC |