PHP code uses ClearImage.dll through COM API. ClearImage DLL is registered as a COM object during installation. To register manually, run the following command as Administrator.
Error 'Class ‘COM’ not found' indicates that the above is not configured.
ClearImage DLL API reports errors as an Exceptionobject.
PHP
<?php
try{// Create ClearImage COM Server
$Server =newCOM("ClearImage.ClearImage");// Your PHP code}catch(Exception $e){
print "Exceptiom in line ". $e->getLine()."\n". $e->getMessage()."\n";}?>
ClearImage project development
Extend functionality
While developing your application, you can combine code examples on this page with methods described in ClearImage API documentation in the ClearImage COM API section.
Barcode Reading
Read 1D barcodes from a page
This example reads code 39 and code 128 barcodes. Set barcode types used in your application. Setting reader->AutoDetect1D=true; automatically finds the barcode type, but it is slower and is not recommended for production.
This example uses some of the most popular image-processing functions. In a production application, the specific sequence of functions should be selected based on specific application needs.
PHP
<?php
functionRepairPage($repair){
$repair->AutoDeskew();
$repair->AutoRotate();
$repair->AutoCrop(10,10,10,10);// Crop to 10 pixels on each side to bitonal
$repair->AdvancedBinarize(0,0,0);// Convert to bitonal an image with complex background patterns
$ciBexBorderDeskewCrop =3;
$ciBeaCleaner =2;
$repair->BorderExtract($ciBexBorderDeskewCrop, $ciBeaCleaner);// Deskew and crop based on black border
$repair->RemovePunchHoles();
$ciSmoothDarkenEdges =1;
$repair->SmoothCharacters($ciSmoothDarkenEdges);
$repair->CleanNoise(3);// Clean balck noise of 3 pixels// $ciCnxBlackNoise = 1; $ciCnxWhiteNoise = 2;// $repair->CleanNoiseExt($ciCnxBlackNoise + $ciCnxWhiteNoise, 3, 3, 10, 0); // Clean black and white noise
$ciLineVertAndHorz =3;
$repair->ReconstructLines($ciLineVertAndHorz);}functionRepair_page($Server, $fileName, $page, $fileOut){
$repair = $Server->CreateRepair();
$repair->Image->Open($fileName, $page);RepairPage($repair);
$repair->Image->SaveAs($fileOut,0);// ciEXT}?>
Repair all images in a multi-page file
This example repairs all images in a multi-page file and saves the result in the fileOut file.