Click here to get back home

Reduce colors with Image::Magick

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Reduce colors with Image::Magick yong321 07-06-2007
Posted by yong321 on July 6, 2007, 7:06 am
Please log in for more thread options


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


Similar ThreadsPosted
image magick through apt-get November 27, 2004, 5:48 pm
Image magick palette July 30, 2004, 9:16 pm
Image::Magick newbie September 5, 2005, 10:19 pm
Image Magick code help November 29, 2004, 12:14 pm
Image Magick code help December 3, 2004, 6:43 pm
Errror in mod Image::magick or something else? October 29, 2005, 4:53 am
ANNOUNCE: Image::Magick::Tiler V 1.00 February 22, 2005, 11:35 am
ANNOUNCE: Image::Magick::Chart V 1.01 June 13, 2005, 3:36 am
Image::Magick scalar value to print use CGI April 13, 2006, 10:09 pm
Problems Installing Image::Magick September 26, 2006, 3:35 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap