static function generate_barcode($string='EXAMPLE', $convert='png', $enctype='code128b') {
$string = escapeshellarg($string);
$enctype = escapeshellarg($enctype);
- $convert = $convert ? " | convert -colorspace gray -background white - $convert:-" : '';
+ $convert = $convert ? " | convert - -crop 0x60+0+30\\! -background none -flatten $convert:-" : '';
return shell_exec("barcode -e $enctype -E -b $string$convert");
}
}
static function download_barcode($string='EXAMPLE', $convert='png', $enctype='code128b') {
- if(self::test()) header('Content-Type: image/png'); else die();
+ if(self::test()) {
+ header('Content-Type: image/png');
+ header('Cache-Control: max-age=604800, public'); //1week caching
+ } else die();
+ error_reporting(0); //TODO: enable errors again
die(self::cached_barcode($string,$convert,$enctype));
}
}