http://www.perlmonks.org?node_id=265149

elbie has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use Tk to superimpose two images, then write them back out again, but I'm getting an error "too many colors at /Library/Perl/darwin/Tk.pm line 228."

Here's a scaled down script that reproduces the error:

#! /usr/bin/perl -w use strict; use Tk; my( $background, $score_pip ); # Main { my $top = MainWindow->new(); $background = $top->Photo( -file => "QBackground.gif", # -palette => 256/256/256, ); $score_pip = $top->Photo( -file => "Score.gif", # -palette => 256/256/256, ); $background->copy( $score_pip, -to => ( 180 - 16, 180 - 16 )); # $background->redither; $background->write( 'testout.gif', -format => 'gif', # -grayscale, ); }

I tried playing with the palette options, and the redither method (commented out above) to see if they would help, but they didn't.

The greyscale option helped, of course, but the image was in greyscale. Not so good.

Also, is there a way to generate a Photo object without creating it using a parent object? I tried $foo = Tk::Photo( ... ) and similar, but those didn't seem to work.

elbieelbieelbie