Reduce colors with Image::Magick

Y

yong321

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top