Open hbh112233abc opened 4 years ago
I suggest createImages
change as below code:
private function createImages($output)
{
$image = array();
$valueStartIndex = null;
$valueEndIndex = null;
foreach ($output as $key => $singleLine) {
if (preg_match('/\(format/', $singleLine)) {
$imageInfo = $singleLine;
$startPos = strpos($imageInfo, "(") + 1;
$endPos = strpos($imageInfo, ")");
$dataStr = substr($imageInfo, $startPos, $endPos - $startPos);
$dataExplode = explode(",", $dataStr);
$contentFormat = explode(":", $dataExplode[0]);
$format = $contentFormat[1];
$contentFormat = explode(":", $dataExplode[1]);
$type = $contentFormat[1];
$valueStartIndex = $key + 2;
$exploded = explode(" ", $singleLine);
$imagePath = array_shift($exploded);
} else if (preg_match('/No barcode found/', $singleLine)) {
$exploded = explode(" ", $singleLine);
$imagePath = array_shift($exploded);
$image[] = new ZxingBarNotFound($imagePath, 101, "No barcode found");
} else if (preg_match('/Parsed result/', $singleLine)) {
$valueEndIndex = $key;
$valueArray = array_slice($output, $valueStartIndex, $valueEndIndex - $valueStartIndex);
$imageValue = implode(' ', $valueArray);
$image[] = new ZxingImage($imagePath, $imageValue, $format, $type);
}
}
return $image;
}
get imageValue from every Raw result
to Parsed result
, and use blank space join multi line text
output example:
PHPZxingDecoder.php function
createImages
set$imageValue = $output[$key+2];
will only get first line text