in reply to Re: Why is Tk::Animation so slow?
in thread Why is Tk::Animation so slow?
I mentioned a 22MB GIF that didn't load after 45 minutes. It's actually 28MB and your code loads it in ~7 seconds! A tremendous improvement.
The 28MB GIF I was working with is some gorgeous footage of Comet ISON grazing the sun taken with the Large Angle Coronagraph on NASA/ESA's Solar Heliospheric Observatory. This version of your script downloads and displays it (The minor glitches in the upper left corner are not part of the GIF. Maybe fixable by setting a proper DisposalMethod):
#!/usr/bin/perl use strict; use warnings; use HTTP::Tiny; use MIME::Base64; use Time::HiRes 'time'; use Imager ':handy'; use Tk; use Tk::Animation; use Tk::Photo; my $file = 'http://web.archive.org/web/20131202114602if_/'. 'http://science.nasa.gov/media/medialibrary/2013/12/01/ghost_anim.gif' +; print "Downloading image $file \n"; my $path = HTTP::Tiny->new->get($file)->{content}; die 'Download failed!' unless $path; my $size = length $path; my $mw = MainWindow-> new; $mw-> configure( -title => 'Comet ISON via SOHO LASCO C3' ); my $top = $mw-> Frame-> pack; my $start = time; my $backdrop; my @frames = map { if ( $backdrop ) { # not 1st? my $mask = $_-> copy; my @mask_plt = map NC( 255, 255, 255 ), $mask-> getcolors; my $trans_idx = $mask-> tags( name => 'gif_trans_index' ); $mask_plt[ $trans_idx ] = NC( 0, 0, 0 ) if $trans_idx; $mask-> setcolors( colors => \@mask_plt ); $backdrop-> compose( src => $_, mask => $mask ); } else { $backdrop = $_ } $backdrop-> write( data => \my $data, type => 'bmp' ); $mw-> Photo( -data => encode_base64( $data )); } Imager-> read_multi( data => $path ); my $image_2 = $mw-> Animation; $image_2-> add_frame( @frames ); print "\nImager & Tk::Animation took ", time - $start, " seconds for $size bytes \n"; $top-> Label( -image => $image_2 )-> pack; $image_2-> start_animation; MainLoop; __END__ Imager & Tk::Animation took 6.60826396942139 seconds for 28042970 byte +s
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Why is Tk::Animation so slow? (re: glitches)
by vr (Curate) on Dec 23, 2019 at 11:44 UTC |