PNG filesize

Hi all,

I'm trying to find ways to make the file-size of my PNG images smaller.

When I generate my 660*440px image I get a big 168kb file.
(8bit RGB color model, has an alpha channel (need that) but no
interlacing scheme)

Here it is:
http://metphys.org/eme/T05.png

I'm using the savefig method of-course.

To see how much I could compress it I used pngcrush (the best tool
according to the interwebs) and got it down to 128kb.

But thats still way to large for my intended use. (plotting results
from an operational weather model, see. www.belgingur.is
We are currently using IDL.)

From what I've read about PNG files, which is supposed to be rather
compact image format, it seems to me that the most effective way is
to have an indexed color table.

So to cut it short:

Is there any way to save a PNG file with an indexed color table?

Or do you see any other way to shrink the files?

Best regards.
Einar M. Einarsson
www.belgingur.is

I'd guess PNG won't get much smaller because you have a lot of different
colored pixels. PNG compresses most when you have a sparser plot. I'd
suggest that you try using JPG. It will compress the multi-colored portion
of your plot way down. You may see a few artifacts if you look carefully at
the axes: instead of pixels white,black,white you might get
white,grey,black,grey,white.

···

-----Original Message-----
From: matplotlib-users-bounces@lists.sourceforge.net
[mailto:matplotlib-users-bounces@lists.sourceforge.net] On Behalf Of
Einar M. Einarsson
Sent: Monday, March 17, 2008 5:08 AM
To: matplotlib-users@lists.sourceforge.net
Subject: [Matplotlib-users] PNG filesize

Hi all,

I'm trying to find ways to make the file-size of my PNG images smaller.

When I generate my 660*440px image I get a big 168kb file.
(8bit RGB color model, has an alpha channel (need that) but no
interlacing scheme)

Here it is:
http://metphys.org/eme/T05.png

I'm using the savefig method of-course.

To see how much I could compress it I used pngcrush (the best tool
according to the interwebs) and got it down to 128kb.

But thats still way to large for my intended use. (plotting results
from an operational weather model, see. www.belgingur.is
We are currently using IDL.)

From what I've read about PNG files, which is supposed to be rather
compact image format, it seems to me that the most effective way is
to have an indexed color table.

So to cut it short:

Is there any way to save a PNG file with an indexed color table?

Or do you see any other way to shrink the files?

Best regards.
Einar M. Einarsson
www.belgingur.is

-----------------------------------------------------------------------
--
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Einar M. Einarsson wrote:

Hi all,

I'm trying to find ways to make the file-size of my PNG images smaller.

When I generate my 660*440px image I get a big 168kb file.
(8bit RGB color model, has an alpha channel (need that) but no
interlacing scheme)

Here it is:
http://metphys.org/eme/T05.png

I'm using the savefig method of-course.

To see how much I could compress it I used pngcrush (the best tool
according to the interwebs) and got it down to 128kb.

But thats still way to large for my intended use. (plotting results
from an operational weather model, see. www.belgingur.is
We are currently using IDL.)

From what I've read about PNG files, which is supposed to be rather
compact image format, it seems to me that the most effective way is
to have an indexed color table.

So to cut it short:

Is there any way to save a PNG file with an indexed color table?

Perhaps this should be supported natively in mpl; but until it is, you can do the conversion after the fact using pngquant or pngnq. Presumably, if you don't in fact have more than 256 colors, this conversion will be lossless.

I have not tried this; my suggestion is based on the descriptions of pngquant and pngnq packages in Ubuntu feisty. Here is the latter:

···

--------------------------------
tool for optimizing PNG (Portable Network Graphics) images
Pngnq is a tool for quantizing 32-bit RGBA PNG images to 8-bit RGBA pallete
PNG. It's is an adaptation by Stuart Coyle of Greg Roelf's pnqquant. While
pngquant uses a median cut algorithm, Pngnq uses Anthony Dekker's neuquant
algorithm (http://members.ozemail.com.au/~dekker/NEUQUANT.HTML), generally
resulting in better looking results than pngquant.

Optimizers (like pngcrush and optipng) optimize the compression, usually
losslessly. pngnq quantizes colors down to 256 (or fewer) distinct RGBA
combinations, which is quite lossy. Optimized PNGs are usually two to four
times smaller than the 32-bit versions.

  Homepage: http://www.cybertherial.com/pngnq/pngnq.html
-----------------------------------------------

Or do you see any other way to shrink the files?

Best regards.
Einar M. Einarsson
www.belgingur.is

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options