【问题标题】:Saving a generated barcode using the Zend library in Codeigniter使用 Codeigniter 中的 Zend 库保存生成的条形码
【发布时间】:2013-06-03 14:18:53
【问题描述】:

想知道是否有人可以提供帮助,

我正在使用 codeigniter 中的 Zend 条码库来自动生成条码,当我访问 URL 时工作正常,但我想将图像保存为服务器上的 jpeg,但这并不适合又名它不会创建图像,

我通过 codeigniter 图像类使用 URL 作为图像源,

提前致谢

【问题讨论】:

    标签: php image codeigniter zend-framework barcode


    【解决方案1】:

    我以其他方式解决了这个问题。

    $config = new Zend_Config(array(
        'barcode'        => 'code39',
        'barcodeParams'  => array('text' => 'TestCode', 'barHeight'=>30, 'factor'=>2),
        'renderer'       => 'image',
        'rendererParams' => array('imageType' => 'gif'),
    ));
    
    $barcode = Zend_Barcode::factory($config);
    
    imagegif($barcode->draw(), 'barcode-img/barcode.gif');
    

    文件放置内容不起作用

    【讨论】:

    • 我不得不使用相同的方法。此处针对 Zend 2.0 进行了更新(有关文档,请参阅 Zend Docs):$imageResource = Zend\Barcode\Barcode::draw( 'code128', 'image', $barcodeOptions, $rendererOptions ); imagepng($imageResource, $imageFilename);
    【解决方案2】:

    您所要做的就是将图像写入文件。

    $imageResource = Zend_Barcode::draw('code39', 'image', $barcodeOptions, $rendererOptions);
    file_put_contents($filename, $imageResource);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多