ClearImage SDK
Programming
PHP
step 1 install clearimage sdk download and install the clearimage sdk step 2 configure clearimage php code uses clearimage dll clearimage dll through com api clearimage dll is registered as a com object during installation to register manually, run the following command as administrator " c \program files (x86)\inlite\clearimagesdk \register bat" add this section to php ini php ini if it has not been set yet \[php com dotnet] extension=php com dotnet dll fastcgi impersonate = 0 \[php com dotnet] extension=php com dotnet dll fastcgi impersonate = 0 error 'class ‘com’ not found' indicates that the above is not configured clearimage dll api reports errors as an exception exception object \<?php try { // create clearimage com server $server = new com("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 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; reader >autodetect1d=true; automatically finds the barcode type, but it is slower and is not recommended for production \<?php function readbarcode1d page ($server, $filename, $page) { 	$reader = $server >createbarcodepro(); 	$cibfcode39 = 2; $cibfcode128 = 4; 	$reader >type = $cibfcode39 + $cibfcode128; 	$reader >image >open($filename, $page); 	$bccount = $reader >find(0); 	for ($i=1;$i<=$bccount;$i++) { 	 $bc = $reader >barcodes($i); 	 print "text " $bc >text "\n"; 	 } } ?> read 2d barcode from a page this example reads pdf417, datamatrix, and qr code \<?php function readbarcode2d page ($server, $filename, $page) { 	$reader = $server >createqr(); 	// $reader = $server >createpdf417(); 	// $reader = $server >createdatamatrix(); 	$reader >image >open($filename, $page); 	$bccount = $reader >find(0); 	for ($i=1;$i<=$bccount;$i++) { 	 $bc = $reader >barcodes($i); 	 print "text " $bc >text "\n"; 	 } } ?> 2d barcodes might contain binary data in $bc >data $bc >data property as an integer array to access all elements foreach ($bc >data as $val) {print " " $val;} read postal barcodes from a page this example reads postal barcodes from an image file page \<?php function readbarcodepostal page ($server, $filename, $page) { 	$reader = $server >createbarcodepro(); $cibf4state = 0x2000000; 	$reader >type = $cibf4state; 	$reader >image >open($filename, $page); 	$bccount = $reader >find(0); 	for ($i=1;$i<=$bccount;$i++) { 	 $bc = $reader >barcodes($i); $type1 =$bc >type; if ($type1 == 33) echo " us intelligent mail "; // cibuspsintelligentmail = 33 if ($type1 == 34) echo "uk royal mail "; // cibbpopostcode = 34 if ($type1 == 35) echo "australian mail "; // cibaustralianpost = 35 if ($type1 == 37) echo "singapore mail "; // cibsingaporepost = 37 	 print " text " $bc >text "\n"; 	 } } ?> read driver's license barcode this example reads the driver's license barcode from an image file page \<?php function readbarcodedriverlic page ($server, $filename, $page) { 	$reader = $server >createpdf417(); 	$reader >image >open($filename, $page); 	$bccount = $reader >find(0); 	for ($i=1;$i<=$bccount;$i++) { 	 $bc = $reader >barcodes($i); 	 print "text " $bc >text "\n"; 	 if ($bc >info("last") != "") 	 { 	 print "last " $bc >info("last") "\n"; 	 print "first " $bc >info("first") "\n"; 	 print "middle " $bc >info("middle") "\n"; 	 print "suffix " $bc >info("suffix") "\n"; 	 print "dob " $bc >info("dob") "\n"; 	 print "eyes " $bc >info("eyes") "\n"; 	 print "hair " $bc >info("hair") "\n"; 	 print "sex " $bc >info("sex") "\n"; 	 print "height " $bc >info("height") "\n"; 	 print "weight " $bc >info("weight") "\n"; 	 print "street " $bc >info("street") "\n"; 	 print "city " $bc >info("city") "\n"; 	 print "state " $bc >info("state") "\n"; 	 print "postal " $bc >info("postal") "\n"; 	 print "country " $bc >info("country") "\n"; 	 print "id " $bc >info("id") "\n"; 	 print "issued " $bc >info("issued") "\n"; 	 print "expires " $bc >info("expires") "\n"; 	 } 	} } ?> read from a multi page image file this example reads barcodes from a single page file or all pages of a multi page image file \<?php function readbarcode1d file ($server, $filename) { 	$reader = $server >createbarcodepro(); 	$cibfcode39 = 2; $cibfcode128 = 4; 	$reader >type = $cibfcode39 + $cibfcode128; 	$page=1; 	while(true) { 	$reader >image >open($filename, $page); 	$bccount = $reader >find(0); 	// process results 	for ($i=1;$i<=$bccount;$i++) { 	 $bc = $reader >barcodes($i); 	 $bc = $reader >barcodes($i); 	 print "page " $page " text " $bc >text "\n"; 	 } 	$page++; 	if ($page > $reader >image >pagecount)	 	 break; 	} } ?> optimize barcode reading this optimize barcode reading docid\ smk4 lgrtfex0zacvu2lv describes methods for improving the recognition rate and/or speed image processing repair image page 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 function repairpage ($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); } function repair 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 fileout file \<?php function repair file ($server, $filename, $fileout) { 	$repair = $server >createrepair(); 	$page=1; 	while(true) 	{ 	 $repair >image >open($filename, $page); 	 repairpage ($repair); // see above 	 $repair >image >append($fileout, 0); // ciext 	 $page++; 	 if ($page > $repair >image >pagecount) 	 break; 	} } ?>