There's a bug in your program above, when used for PNG or JPEG. It's a
perl error and I expect you would have got an answer on perlmonks as I
suggested.
The error is described on
https://docstore.mik.ua/orelly/perl3/tk/ch17_01.htm
Look for "Notice the Photo image formats JPEG, PNG, and TIFF—not part
of the Perl/Tk distribution—must be specifically imported."
Only the .bmp file displays other files have error.
"Uncaught exception from user code:
couldn't recognize data in image file "images/red.png" at
/usr/lib/x86_64-linux-gnu/perl5/5.38/Tk/Image.pm line 21.
Tk::Image::new("Tk::Photo", MainWindow=HASH(0x560632dc9098),
"-file", "images/red.png") called at
/usr/lib/x86_64-linux-gnu/perl5/5.38/Tk/Image.pm line 63
Tk::Image::__ANON__(MainWindow=HASH(0x560632dc9098), "-file",
"images/red.png") called at ./test-image.pl line 8"
I've installed
Tk, libgraphics-magick-perl, libimage-imlib2-perl, tkagif, tkblt,
tklib, libtk-img, tkpng.
Now that I know .bmp works I can use that.
Wonder tho' why others don't display, Bookworm and Trixie.
If there is some other module to include I can't discover what it's
name is as yet.
Tk::Photo is a module but seems to be included in Perl/Tk
I'm not really understanding if the Perl/Tk is a rewrite or an
interface to Tk modules.
You might want to read the book! :) Or even the CPAN entry for Tk if
you want to understand more.