From: Darold Gilles Date: Fri, 4 May 2012 15:00:46 +0000 (+0200) Subject: Add --image-format to allow the change of the default png image format to jpeg X-Git-Tag: v3.2~245 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bdae45b06148037f46c9957aa8d7e3e641c2a397;p=pgbadger Add --image-format to allow the change of the default png image format to jpeg --- diff --git a/pgbadger b/pgbadger index 28ad7ff..416ae3b 100755 --- a/pgbadger +++ b/pgbadger @@ -61,7 +61,7 @@ my $progress = 0; my $NUMPROGRESS = 10000; my @DIMENSIONS = (800,300); my $RESRC_URL = ''; -my $IMG_FORMAT = 'png'; +my $img_format = 'png'; # Do not display data in pie where percentage is lower than this value # to avoid label overlaping. @@ -92,6 +92,7 @@ my $result = GetOptions ( "q|quiet!" => \$quiet, "p|progress!" => \$progress, "pie-limit=i" => \$pie_percentage_limit, + "image-format=s" => \$img_format, ); if ($ver) { @@ -139,6 +140,11 @@ $pie_percentage_limit = 0 if ($pie_percentage_limit < 0); $pie_percentage_limit = 2 if ($pie_percentage_limit eq ''); $pie_percentage_limit = 100 if ($pie_percentage_limit > 100); +# Set default download image format +$img_format = lc($img_format); +$img_format = 'jpeg' if ($img_format eq 'jpg'); +$img_format = 'png' if ($img_format ne 'jpeg'); + # Extract the output directory from outfile so that graphs will # be created in the same directoty my @infs = fileparse($outfile); @@ -2291,7 +2297,7 @@ document.writeln('" ); } - graph.download.saveImage('$IMG_FORMAT'); + graph.download.saveImage('$img_format'); }; document.getElementById('toimage$buttonid').onclick = function() { if (Flotr.isIE && Flotr.isIE < 9) { @@ -2300,7 +2306,7 @@ document.writeln('" ); } - graph.download.saveImage('$IMG_FORMAT', null, null, true); + graph.download.saveImage('$img_format', null, null, true); }; })(document.getElementById("$divid")); @@ -2370,7 +2376,7 @@ document.writeln('" ); } - graph.download.saveImage('$IMG_FORMAT'); + graph.download.saveImage('$img_format'); }; document.getElementById('toimage$buttonid').onclick = function() { if (Flotr.isIE && Flotr.isIE < 9) { @@ -2379,7 +2385,7 @@ document.writeln('" ); } - graph.download.saveImage('$IMG_FORMAT', null, null, true); + graph.download.saveImage('$img_format', null, null, true); };