Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with fetching barcode #3

Open
it-can opened this issue Jan 7, 2013 · 21 comments
Open

problem with fetching barcode #3

it-can opened this issue Jan 7, 2013 · 21 comments

Comments

@it-can
Copy link

it-can commented Jan 7, 2013

Hi I am getting this error on PHP 5.4.10

[07-jan-2013 21:10:37] WARNING: [pool php-fpm-1] child 434 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Uncaught exception 'zbarcodeexception' with message 'Unable to read the image' in 123.php:3"
[07-jan-2013 21:10:37] WARNING: [pool php-fpm-1] child 434 said into stderr: "Stack trace:"
[07-jan-2013 21:10:37] WARNING: [pool php-fpm-1] child 434 said into stderr: "#0 123.php(3): zbarcodeimage->__construct('123.jpg')"
[07-jan-2013 21:10:37] WARNING: [pool php-fpm-1] child 434 said into stderr: "#1 {main}"
[07-jan-2013 21:10:37] WARNING: [pool php-fpm-1] child 434 said into stderr: "  thrown in 123.php on line 3"

I am using this code:

/* Create new image object */
$image = new ZBarCodeImage("123.jpg");

/* Create a barcode scanner */
$scanner = new ZBarCodeScanner();

/* Scan the image */
$barcode = $scanner->scan($image);

/* Loop through possible barcodes */
if (!empty($barcode)) {
    foreach ($barcode as $code) {
        printf("Found type %s barcode with data %s\n", $code['type'], $code['data']);
    }
}

I tested with imagick and with gd, gd doesn't throw the error (but also doesnt work). :-(

@mkoppanen
Copy link
Owner

Does 123.jpg exist ?

@it-can
Copy link
Author

it-can commented Jan 10, 2013

jup... any idea?

@mkoppanen
Copy link
Owner

Can you try passing realpath ("123.jpg") as the image? Might be a problem with relative path

@mkoppanen
Copy link
Owner

With the latest commit 'make test' shows following:

=====================================================================
PHP         : /usr/bin/php 
PHP_SAPI    : cli
PHP_VERSION : 5.3.3-7+squeeze14
ZEND_VERSION: 2.3.0
PHP_OS      : Linux - Linux debian 2.6.32-5-amd64 #1 SMP Sun May 6 04:00:17 UTC 2012 x86_64
INI actual  : /tmp/php-zbarcode/tmp-php.ini
More .INIs  :  
CWD         : /tmp/php-zbarcode
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
TIME START 2013-01-14 07:12:18
=====================================================================
PASS Test construction [tests/001-construct.phpt] 
PASS Test reading image and scanning barcode [tests/002-read-barcode.phpt] 
PASS Test setting config [tests/003-setconfig.phpt] 
PASS Test multipage reading and single page reading [tests/004-paged-reading.phpt] 
PASS Test count [tests/005-count.phpt] 
SKIP Check whether imagick integration works [tests/006-imagick.phpt] reason: Imagick extension is not loaded
SKIP Test GD support [tests/007-test-gd.phpt] reason: GD extension is not loaded
=====================================================================
TIME END 2013-01-14 07:12:19

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   44
---------------------------------------------------------------------

Number of tests :    7                 5
Tests skipped   :    2 ( 28.6%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    5 ( 71.4%) (100.0%)
---------------------------------------------------------------------
Time taken      :    1 seconds
=====================================================================

@it-can
Copy link
Author

it-can commented Jan 14, 2013

Ok I'll recompile and test again...

@it-can
Copy link
Author

it-can commented Jan 14, 2013

Still getting the same error:

[14-jan-2013 09:32:30] WARNING: [pool php-fpm-3] child 4092 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Uncaught exception 'zbarcodeexception' with message 'Unable to read the image'
in /home/test/public_html/public/test.php:3"
[14-jan-2013 09:32:30] WARNING: [pool php-fpm-3] child 4092 said into stderr: "Stack trace:"
[14-jan-2013 09:32:30] WARNING: [pool php-fpm-3] child 4092 said into stderr: "#0 /home/test/public_html/public/test.php(3): zbarcodeimage->read('/home/test/public_html/public/ean13.jpg')"
[14-jan-2013 09:32:30] WARNING: [pool php-fpm-3] child 4092 said into stderr: "#1 {main}"
[14-jan-2013 09:32:30] WARNING: [pool php-fpm-3] child 4092 said into stderr: "  thrown in /home/test/public_html/public/test.php on line 3"

my test script:

$image = new ZBarcodeImage();
var_dump($image->read("/home/test/public_html/public/ean13.jpg"));

echo "-----------------------------\n";

$scanner = new ZBarcodeScanner();
var_dump($scanner->scan($image));

$info = $scanner->scan($image, 0, true);
echo gettype($info[1][0]['location']) . "\n";

/* Try to scan empty object */
$image->clear();
try {
var_dump($scanner->scan($image));
} catch (ZBarCodeException $e) {
    echo "Got exception";
}

this is the output of make test

=====================================================================
PHP         : /usr/bin/php 
Warning: PHP Startup: Unable to load dynamic library '/php-zbarcode/modules/zbarcode.so' - /php-zbarcode/modules/zbarcode.so: undefined symbol: phpi_get_le_gd in Unknown on line 0

PHP_SAPI    : cli
PHP_VERSION : 5.4.10
ZEND_VERSION: 2.4.0
PHP_OS      : Linux - Linux server.it-can.nl 2.6.32-279.19.1.el6.x86_64 #1 SMP Wed Dec 19 07:05:20 UTC 2012 x86_64
INI actual  : /php-zbarcode/tmp-php.ini
More .INIs  :  
CWD         : /php-zbarcode
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
TIME START 2013-01-14 09:38:44
=====================================================================
SKIP Test construction [tests/001-construct.phpt] reason: .
SKIP Test reading image and scanning barcode [tests/002-read-barcode.phpt] reason: .
SKIP Test setting config [tests/003-setconfig.phpt] reason: .
SKIP Test multipage reading and single page reading [tests/004-paged-reading.phpt] reason: .
SKIP Test count [tests/005-count.phpt] reason: .
SKIP Check whether imagick integration works [tests/006-imagick.phpt] reason: .
SKIP Test GD support [tests/007-test-gd.phpt] reason: .
=====================================================================
TIME END 2013-01-14 09:38:44

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   29
---------------------------------------------------------------------

Number of tests :    7                 0
Tests skipped   :    7 (100.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :    0 seconds
=====================================================================

@mkoppanen
Copy link
Owner

Two questions:

a) Can you provide ean13.jpg ?
b) Does your ImageMagick lack JPEG support?

@it-can
Copy link
Author

it-can commented Jan 14, 2013

  1. https://github.com/mkoppanen/php-zbarcode/blob/master/tests/ean13.jpg
  2. it supports jpeg

I noticed this error: Warning: PHP Startup: Unable to load dynamic library '/php-zbarcode/modules/zbarcode.so' - /php-zbarcode/modules/zbarcode.so: undefined symbol: phpi_get_le_gd in Unknown on line 0

I use php 5.4.10

@mkoppanen
Copy link
Owner

Can you try compiling php-zbarcode '--without-zbarcode-gd' and see if that helps?

@it-can
Copy link
Author

it-can commented Jan 14, 2013

now i am getting this error:

Warning: PHP Startup: Unable to load dynamic library '/php-zbarcode/modules/zbarcode.so' - /php-zbarcode/modules/zbarcode.so: undefined symbol: php_imagick_get_class_entry in Unknown on line 0

@mkoppanen
Copy link
Owner

hmmm, --without-zbarcode-imagick might help

@it-can
Copy link
Author

it-can commented Jan 14, 2013

mmm, with ./configure --disable-zbarcode-imagick --disable-zbarcode-gd
it seems to pass 5 of the 7 tests... I will test some more

The test passes:

=====================================================================
PHP         : /usr/bin/php 
PHP_SAPI    : cli
PHP_VERSION : 5.4.10
ZEND_VERSION: 2.4.0
PHP_OS      : Linux - Linux server.it-can.nl 2.6.32-279.19.1.el6.x86_64 #1 SMP Wed Dec 19 07:05:20 UTC 2012 x86_64
INI actual  : /php-zbarcode/tmp-php.ini
More .INIs  :  
CWD         : /php-zbarcode
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
TIME START 2013-01-14 13:28:07
=====================================================================
PASS Test construction [tests/001-construct.phpt] 
PASS Test reading image and scanning barcode [tests/002-read-barcode.phpt] 
PASS Test setting config [tests/003-setconfig.phpt] 
PASS Test multipage reading and single page reading [tests/004-paged-reading.phpt] 
PASS Test count [tests/005-count.phpt] 
SKIP Check whether imagick integration works [tests/006-imagick.phpt] reason: Imagick extension is not loaded
SKIP Test GD support [tests/007-test-gd.phpt] reason: GD extension is not loaded
=====================================================================
TIME END 2013-01-14 13:28:08

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   30
---------------------------------------------------------------------

Number of tests :    7                 5
Tests skipped   :    2 ( 28.6%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    5 ( 71.4%) (100.0%)
---------------------------------------------------------------------
Time taken      :    1 seconds
=====================================================================

But when I try to use a script in the browser it doesn;t work...

@it-can
Copy link
Author

it-can commented Jan 14, 2013

also if I try commandline it still doesn't work... It is weird that the tests run correctly...

@mkoppanen
Copy link
Owner

Did you remember to run make install?

@it-can
Copy link
Author

it-can commented Jan 14, 2013

jup

@mkoppanen
Copy link
Owner

That sounds slightly odd because make test should be about the same as running from command-line.

@it-can
Copy link
Author

it-can commented Jan 15, 2013

what php config does the make test use?

@lijinma
Copy link

lijinma commented Aug 28, 2013

Hi, mkoppanen, can i write a wiki page of zbarcode installation on Mac?

The zbarcode.so works perfect on my Mac, thank you so much.

@mkoppanen
Copy link
Owner

Sure, go for it

@zhangdang254
Copy link

Fatal error: Uncaught exception 'zbarcodeexception' with message 'Unable to read the image' in ''
依旧报错啊 请问谁解决了~ 😂

@hy512
Copy link

hy512 commented Sep 4, 2020

Fatal error: Uncaught exception 'zbarcodeexception' with message 'Unable to read the image' in ''
依旧报错啊 请问谁解决了~ 😂

检查 ImageMagick 的 jpeg 支持是否开启.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants