Reduce colors with Image::Magick

Discussion in 'Perl Misc' started by yong321@yahoo.com, Jul 1, 2007.

  1. Guest

    I use this code to test reducing number of image colors (image from
    http://www.libpng.org/pub/png/).

    use Image::Magick;
    $p = new Image::Magick;
    $p->Read("pnglogo-blk-sml1.png");
    $p->Quantize(colors=>64);
    #$p->Posterize(levels=>1, dither=>True);
    $p->Write("pnglogo-blk-sml12.png");

    I use IrfanView to check number of colors (should be the same as
    Get(colors) of Image::Magick). Number of *unique* colors has indeed
    decreased from 256 to 64. But both Original Colors and Current Colors
    reported by IrfanView are still "256 (8 BitsPerPixel)". Since I only
    have 64 colors, how can I reduce bits per pixel to 6?

    The real goal is to reduce file size by sacrificing some colors. Size
    of original image pnglogo-blk-sml1.png is 17260. New image pnglogo-blk-
    sml12.png is 11049. Can this be reduced further?

    Yong Huang
     
    , Jul 1, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric McDaniel

    Image::Magick and Tk::Photo

    Eric McDaniel, Aug 30, 2003, in forum: Perl
    Replies:
    2
    Views:
    1,647
    Joseph Brenner
    Sep 20, 2003
  2. Weapons of Mass Destruction

    Trying to get Image::Magick to work on a remote server

    Weapons of Mass Destruction, Nov 15, 2003, in forum: Perl
    Replies:
    3
    Views:
    553
    Gunnar Hjalmarsson
    Nov 15, 2003
  3. AAaron123

    TreeNode colors come from anchor colors

    AAaron123, Aug 7, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    562
    darrel
    Aug 7, 2008
  4. ZelluX
    Replies:
    3
    Views:
    1,960
    Peter Otten
    Dec 1, 2008
  5. Jack
    Replies:
    2
    Views:
    237
    John W. Krahn
    Jan 25, 2008
Loading...

Share This Page