我想使用 php 将 Data-matrix 库生成 QR 码图像存储到 mysql 数据库中。我正在尝试使用 jpgraph 库。请提供解决方案..
<?php
require_once('jpgraph/datamatrix/datamatrix.inc.php');
$data = '1234567890';
$shape = DMAT_AUTO;
$encoding = ENCODING_AUTO;
$modulewidth = 3;
$quietzone = 10;
$color1 = 'black';
$color0 = 'white';
$colorq = 'white';
$outputfile = '';
// Create and set parameters for the encoder
$encoder = DatamatrixFactory::Create($shape);
$encoder->SetEncoding($encoding);
// Create the image backend (default)
$backend = DatamatrixBackendFactory::Create($encoder);
// By default the module width is 2 pixel so we increase it a bit
$backend->SetModuleWidth($modulewidth);
// Set Quiet zone
$backend->SetQuietZone($quietzone);
// Set other than default colors (one, zero, quiet zone/background)
$backend->SetColor($color1, $color0, $colorq);
// Create the barcode from the given data string and write to output file
try {
$backend->Stroke($data,$outputfile);
} catch (Exception $e) {
$errstr = $e->GetMessage();
echo "Datamatrix error message: $errstr\n";
}
?>