summaryrefslogtreecommitdiffstats
path: root/src/examples/example.php
blob: ddacc22adb1b1bc75f970c8de9a3aa39313ed54f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php 
    require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "PHPZxing" . DIRECTORY_SEPARATOR . "PHPZxingBase.php";
    require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "PHPZxing" . DIRECTORY_SEPARATOR . "PHPZxingDecoder.php";
    require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "PHPZxing" . DIRECTORY_SEPARATOR . "ZxingImage.php";
    require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "PHPZxing" . DIRECTORY_SEPARATOR . "ZxingBarNotFound.php";

    use PHPZxing\PHPZxingDecoder;

    $decoder        = new PHPZxingDecoder();
    $decodedData    = $decoder->decode('../images/Code128Barcode.jpg');
    print_r($decodedData);

    $config = array(
        'try_harder' => true,
        'multiple_bar_codes' => true,
        'crop' => '100,200,300,300',
    );
    $decoder        = new PHPZxingDecoder($config);
    $decodedData    = $decoder->decode('../images/');
    print_r($decodedData);

    $decoder        = new PHPZxingDecoder();
    $imageArrays = array(
        '../images/Code128Barcode.jpg',
        '../images/Code39Barcode.jpg'
    );
    $decodedData    = $decoder->decode($imageArrays);
    print_r($decodedData);

    $config = array(
        'try_harder' => true,
        'multiple_bar_codes' => true
    );
    $decoder        = new PHPZxingDecoder($config);
    $decodedData    = $decoder->decode('../images/multiple_bar_codes.jpg');
    print_r($decodedData);
?>