【发布时间】:2014-01-17 11:57:43
【问题描述】:
我正在使用 PHP 类 Barcode-Coder (http://barcode-coder.com) 将 code128 条形码生成为 GIF。它工作正常,扫描仪可以读取它。但是,我要打印条形码的区域对于图像来说太小了,如果我只是缩小图像,扫描就会失败(逻辑上)。有没有办法设置条的宽度,目前似乎它使用两个像素,这使得它对于我的打印区域来说很宽。 在示例/文档中,有一个在线生成器可以生成条形较细的条码,但我找不到此设置。
我目前使用的代码
$code = isset($_GET["message"]) ? $_GET["message"] : "";
// Settings for barcode
$marge = 0; // between barcode and hri in pixel
$x = 100; // barcode center
$y = 15; // barcode center
$height = 30; // barcode height in 1D ; module size in 2D
$width = 2; // barcode height in 1D ; not use in 2D
$angle = 0; // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
$type = 'code128';
// ALLOCATE GD RESSOURCE
$im = imagecreatetruecolor(200, 30);
$black = ImageColorAllocate($im,0x00,0x00,0x00);
$white = ImageColorAllocate($im,0xff,0xff,0xff);
imagefilledrectangle($im, 0, 0, 200, 30, $white);
// Create barcode
$data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
// Generate image with barcode
header('Content-type: image/gif');
imagegif($im);
imagedestroy($im);
不,遗憾的是,它并不像将 $width 从 2 设置为 1 那样简单。我认为这只是条之间的间距,而不是条本身。
非常感谢任何帮助。
【问题讨论】: