Jouke has asked for the wisdom of the Perl Monks concerning the following question:
I've been asking a few questions regarding Tk lately, and once again, this has to do with Tk.
I have a lot of GIF images, and they all are displayed as buttons. To view them in a matrix of 4x4, they are all resized to a certain $MAX_HEIGHT and $MAX_WIDTH like this:
The problem I have is that I actually want all images to have the exact same width. With this code (using $scaledimage->copy($images[$y], -subsample => $scalefactor) it's only possible to use integers as $scalefactor.
I know I can use PerlMagick to resize images, save them and reload them again, but that takes two more disk-actions, and the whole thing isn't that fast already.
Is is possible to scale an image in Tk with 'floats' ? Rescaling with integers makes images either large or small...
Jouke Visser, Perl 'Adept'
I have a lot of GIF images, and they all are displayed as buttons. To view them in a matrix of 4x4, they are all resized to a certain $MAX_HEIGHT and $MAX_WIDTH like this:
this snippet of code is executed within a loop (that's why the @images exists)...$images[$y] = $mainframe->Photo(-file => "$file.gif"); my ($height, $width) = ($images[$y]->height, $images[$y]->widt +h); my $yfactor = $height/$MAX_HEIGHT; my $xfactor = $width/$MAX_WIDTH; my $scalefactor = $xfactor > $yfactor ? int($xfactor) : int($y +factor); $scalefactor +=1; my $scaledimage = $mainframe->Photo("button$y"); $scaledimage->copy($images[$y], -subsample => $scalefactor); $images[$y]->destroy();
The problem I have is that I actually want all images to have the exact same width. With this code (using $scaledimage->copy($images[$y], -subsample => $scalefactor) it's only possible to use integers as $scalefactor.
I know I can use PerlMagick to resize images, save them and reload them again, but that takes two more disk-actions, and the whole thing isn't that fast already.
Is is possible to scale an image in Tk with 'floats' ? Rescaling with integers makes images either large or small...
Jouke Visser, Perl 'Adept'
|
---|
Replies are listed 'Best First'. | |
---|---|
(ichimunki) re: Resizing images && Tk
by ichimunki (Priest) on Mar 14, 2001 at 03:42 UTC | |
Re: Resizing images && Tk
by archon (Monk) on Mar 14, 2001 at 03:39 UTC | |
by Jouke (Curate) on Mar 14, 2001 at 15:03 UTC | |
Re: Resizing images && Tk
by Jouke (Curate) on Mar 14, 2001 at 17:32 UTC |
Back to
Seekers of Perl Wisdom