Image::Magic is a very powerful module to manipulate images. It may be of help to you. As an example, I use the following script to generate HTML formatted thumbnails from a directory of pictures. You can surely use the same concept in Tk.

use strict; use English; use Warnings; use Image::Magick; use Image::Magick::Thumbnail; opendir(DIR,$ARGV[0]) || die "Can't open directory: $!\n"; open(FIL,">$ARGV[0]/index.html") || die "Can't write html file: $!\n"; print FIL "<html><body><center><table border=1 cellpadding=3 cellspaci +ng=3><tr>"; mkdir("$ARGV[0]/Thumbnails") unless (-d "$ARGV[0]/Thumbnails"); mkdir("$ARGV[0]/Reduced") unless (-d "$ARGV[0]/Reduced"); my $i=1; foreach (sort grep {/jpg$/i} readdir(DIR)){ if (/Censored/){ print "skipping $_\n"; next; } print "reading $_\n"; my $img = new Image::Magick; $img->Read("$ARGV[0]/$_"); my ($thumb,$x,$y) = Image::Magick::Thumbnail::create($img,640); $thumb->Write("$ARGV[0]/Reduced/$_"); ($thumb,$x,$y) = Image::Magick::Thumbnail::create($img,100); $thumb->Write("$ARGV[0]/Thumbnails/$_"); print FIL "<td><center><a href=\"Reduced/$_\"><img src=\"Thumbnails/ +$_\"></a><br><font face=\"Times New Roman\" size=\"2\"><a href=\"$_\" +>Lrg</a></font></center></td>"; if (!($i++ % 6)) {print FIL "</tr><tr>";} } print FIL "</tr></table></center></body></html>"; close(FIL); closedir(DIR);

In reply to Re: Perl/Tk widget for displaying images and thumbnails by gri6507
in thread Perl/Tk widget for displaying images and thumbnails by biochris

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.