Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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/ 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.


In reply to too many colors, using Tk to write images by elbie

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-06-13 10:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.