We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

Read Barcodes From Image in PHP Using Aspose.BarCode REST API Takes Too Long

Hi, we are testing barcode recognition (code128) with SDK for PHP. We created free account, and started to testing out how this tool could work for us.
Response time is 30-60s per single image. We tried to upload photo to API or just set URL to image (image size is 600x900px, 67kB).
Can we make it works faster?


Please note while you read the barcode from image in PHP using Aspose.BarCode REST API, you need to set an explicit barcode type hint for the respective barcode type for better performance. Hopefully, it will resolve the issue.

Steps to Read Barcode From Image in PHP

  • Free signup with aspose.cloud to get credentials
  • Install Aspose.BarCode Cloud SDK for PHP from Packagist
  • Create a PHP Script file and add reference Aspose.BarCode Cloud SDK for PHP
  • Create an instance of Aspose.BarCode REST API
  • Create PostBarCodeRecognizeFromUrlorContentRequest object and set the barcode image and barcode hint and other required properties
  • Pass the request object to PostBarCodeRecognizeFromUrlorContent and run the code to read the barcode

Sample PHP Code to Scan Barcode From Image Online



//TODO: Get your ClientId and ClientSecret at https://dashboard.aspose.cloud (free registration is required).

// Create an instance of API
$config = new Aspose\BarCode\Configuration();
$api = new Aspose\BarCode\BarcodeApi(null, $config);

try {
	// Read barcode from local image
	$request = new Aspose\BarCode\Requests\PostBarCodeRecognizeFromUrlorContentRequest();
    $request->image = new SplFileObject('Barcode.png');
    $request->preset = Aspose\BarCode\Model\PresetType::HighPerformance;
	$request->type = Aspose\BarCode\Model\EncodeBarcodeType::Code128;
	$result = $api->PostBarCodeRecognizeFromUrlorContent($request);	
} catch (Exception $e) {
    echo  "Something went wrong: ",  $e->getMessage(), "\n";