fix GDImage raw data
This commit is contained in:
@@ -90,7 +90,6 @@ class OCRController extends ApiController
|
|||||||
if ($tesseractAllowlist !== null) {
|
if ($tesseractAllowlist !== null) {
|
||||||
$ocr->allowlist($tesseractAllowlist);
|
$ocr->allowlist($tesseractAllowlist);
|
||||||
}
|
}
|
||||||
$result = $ocr->run(500);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +99,14 @@ class OCRController extends ApiController
|
|||||||
$result = '';
|
$result = '';
|
||||||
$img = imagecreatefromstring($curlResult);
|
$img = imagecreatefromstring($curlResult);
|
||||||
if ($img !== false && (($options !== null && imagefilter($img, $filter, $options) === true) || ($options === null && imagefilter($img, $filter) === true))) {
|
if ($img !== false && (($options !== null && imagefilter($img, $filter, $options) === true) || ($options === null && imagefilter($img, $filter) === true))) {
|
||||||
$ocr->imageData($img, $curlSize);
|
|
||||||
|
ob_start();
|
||||||
|
imagepng($img);
|
||||||
|
$imgData = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
$imgDataSize = strlen($imgData);
|
||||||
|
|
||||||
|
$ocr->imageData($imgData, $imgDataSize);
|
||||||
imagedestroy($img);
|
imagedestroy($img);
|
||||||
|
|
||||||
$result = $ocr->run(500);
|
$result = $ocr->run(500);
|
||||||
@@ -124,14 +130,14 @@ class OCRController extends ApiController
|
|||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
imagepng($dstImage);
|
imagepng($dstImage);
|
||||||
$imgOutput = ob_get_contents();
|
$imgData = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
$imgSize = strlen($imgOutput);
|
$imgDataSize = strlen($imgData);
|
||||||
|
|
||||||
imagedestroy($srcImage);
|
imagedestroy($srcImage);
|
||||||
imagedestroy($dstImage);
|
imagedestroy($dstImage);
|
||||||
|
|
||||||
$ocr->imageData($dstImage, $imgSize);
|
$ocr->imageData($dstImage, $imgDataSize);
|
||||||
$result = $ocr->run(500);
|
$result = $ocr->run(500);
|
||||||
return $result;
|
return $result;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user