I have been working with Imager for about a week now and would like to know how to better control the palette. I have an image that has some high-saturation colors in a small number of pixels. I create a paletted image with this type of call:
my $paletted_img = $img->to_paletted({max_colors => 12, colors => \@colors, });
I have noticed that the palette seems to consist of a lot of neutral, low-saturation colors. I suppose they have less color quantization error for more neutral and prevalent pixels. I would like to have some control over the palette so that I can preserve some of the high-saturation colors. I'd like to be able to specify one or two of the colors in the palette and let the module determine the other 10 or 11 colors. I can't find a lot of sample code on how to control how the pallete is formed, and the documentation I've found says that specifying a color list is a feature to be added to Imager in the future. Can anyone please help me fix one or two colors in the palette? Thanks.

In reply to control palette with Imager by johnrcomeau

Title:
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, details, 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, summary, 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.