[rrd-developers] Patch: new --compression-level option

Bernhard Fischer rep.dot.nop at gmail.com
Sat Jul 7 20:02:15 CEST 2007


On Sat, Jul 07, 2007 at 06:35:59PM +0200, Vincent Pit wrote:
>Hello,
>
>Images are currently generated as fast as possible, but in some
>situations CPU time is cheaper than bandwidth. This patch implements a
>new --compression-level option for rrdgraph to adjust the compression
>level (sic) of the graphs. It takes a nonnegative integer as its argument.
>This setting has currently only a meaning for PNG images, where it is
>used as the zlib compression level (i.e. 0 for no compression to 9 for
>best compression). We can also imagine to use greater values to switch
>between PNG compression methods (e.g 27 for the method 2 and compression
>7). The default value has been kept to 1, like the current behaviour.
>Specifying this setting has no incidence on all the other formats (it is
>not rejected).
>
>Regards,
>
>Vincent Pit.
>

>--- doc/rrdgraph.pod	2007-05-02 20:06:13.000000000 +0200
>+++ doc/rrdgraph.pod	2007-07-07 16:41:23.000000000 +0200
>@@ -332,6 +332,11 @@
> Helvetica-BoldOblique, Helvetica-Oblique, Helvetica, Symbol,
> Times-Bold, Times-BoldItalic, Times-Italic, Times-Roman, and ZapfDingbats.
> 
>+[B<-C>|B<--compression-level> I<level>]
>+
>+Currently used only with PNG images. Set the compression level from 0
>+(no compression, fastest) to 9 (best compression, slowest). Default is 1.
>+
> [B<-i>|B<--interlaced>]
> 
> If images are interlaced they become visible on browsers more quickly.
>--- src/rrd_gfx.c	2007-05-02 20:06:10.000000000 +0200
>+++ src/rrd_gfx.c	2007-07-07 16:36:39.000000000 +0200
>@@ -99,6 +99,7 @@
>     canvas->zoom = 1.0;
>     canvas->font_aa_threshold = -1.0;
>     canvas->aa_type = AA_NORMAL;
>+    canvas->compression = 1;
>     return canvas;
> }
> 
>@@ -526,7 +527,7 @@
> 
> 
> static int gfx_save_png (art_u8 *buffer, FILE *fp,
>-                     long width, long height, long bytes_per_pixel);
>+               long width, long height, long bytes_per_pixel, long compression);

Wouldn't it be better to just pass a pointer to a
typedef gfx_s {
	long width;
	long height;
	long bbp;
	int compression;
} gfx_output_t;
instead?

cheers,

PS: If you're concerned about bandwidth, then i'd use a compressed
stream to push the images to it's destination. I'm sure there are
possibilities to use liblzma/libbz2 or the like that are listening on a
socket. If not, this is a) trivially implemented b) also helps non-PNG.
Just a thought.



More information about the rrd-developers mailing list