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 fairly certain there's no way to create a Tk::Photo without a parent widget, as it assumes a certain amount of context that's provided by the parent.

My guess regarding running out of colors is that the palettes of the GIF files contain slightly different colors, so they can't be combined naively. I don't know which line of the code you posted is line 228 and generating the error, but if it's the copy line, then the redither won't help because the program never gets to that point. Update: The redither won't help regardless, as it doesn't actually reduce the colors used by the image. If I understand the docs correctly, it's for display purposes only.

If it's the write line, then it may be that the combined palettes contain too many colors to be supported by GIF (IIRC, GIF only supports up to 256 colors per image block; though you can do some trickery using multiple image blocks to get more than 256 colors total in the image, I'd be willing to bet Tk doesn't support that).

The best bet I can think of (and, of course, that doesn't mean the best bet in general ;) would be to reduce the number of palette entries used in the original images.

In the end, however, I think you'd be better served by looking into the other image processing modules available, such as Image::Magick or GD, as their more sophisticated features would probably make this job easier.

Good luck.

Update: Oh, and I assume it's just a typo, but you would need quotes around the value you're passing to the palette option for the code to compile.

Black flowers blossom
Fearless on my breath

In reply to Re: too many colors, using Tk to write images by bbfu
in thread 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":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • 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 musing on the Monastery: (2)
    As of 2024-07-21 01:32 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.