sub show_next_image { my( $id, $filename ) = get_next_pic(); my $raw_image = $Image_Window->Photo( '-format' => 'jpeg', -file => $filename ); my ($img_w, $img_h) = ($raw_image->width, $raw_image->height); my $max_width = $Main->screenwidth()-20; my $max_height = $Main->screenheight()-75; my $xfactor = $img_w / $max_width; my $yfactor = $img_h / $max_height; my $intfactor = $xfactor > $yfactor ? int($xfactor) : int($yfactor); $intfactor += 1; my $image = $Image_Window->Photo(); $image->copy( $raw_image, -subsample => $intfactor); my $reduced_flag = ( $raw_image->width == $image->width ) ? 'full-size' : "reduced by $intfactor"; $Image_Window->delete( '0.1', 'end' ); $Image_Window->insert( '0.1', "$reduced_flag\n" ); my $image_widget = $Image_Window->imageCreate( 'end', -image => $image ); $raw_image->destroy(); $image->destroy(); }