r/PHPhelp • • Oct 12 '23

[PHP] How do I read barcodes from an image?

I don’t recall the program that always comes up when I’m searching for this. But it requires backend installation. Which I am pretty certain on my Hostinger CPanel I don’t have access to.

So is there any other way of achieving this without operating system level control?

Essentially I want to be able to do this:

$imageURL = “/files/picture.png”;

$Barcode = ScanBarcodes($imageURL);

echo $Barcode;

9 Upvotes

13 comments sorted by

4

u/richardathome Oct 13 '23

It might not fit your use case, but a bar code scanner works just like a usb keyboard. You don't need to process any images. Point the scanner at the barcode and it outputs the string that represent the barcode as if someone just typed it on a keyboard.

1

u/AEWExcalibur Oct 13 '23

Yes I understand that mate. But unfortunately it isn’t much help for me as I am trying to automate processes

0

u/[deleted] Oct 13 '23

[deleted]

2

u/AEWExcalibur Oct 13 '23

I’m not taking a picture. I have a library of pictures.

2

u/Tunnelboy77 Oct 13 '23

Yes this is correct. I needed to keep track of my inventory at trade shows, so I built a PHP register. The main screen just had an input box on it. When I scanned a product, it would go right into the input field and then my code would remove it from inventory. Worked great. And the cheap barcode readers can read incredibly small barcodes.

1

u/richardathome Oct 13 '23

I was senior dev at a *very* busy warehouse for the last decade. Of all the hardware we used, the hand scanners were the most reliable.

3

u/[deleted] Oct 13 '23 edited Oct 13 '23

You mean like this library, which was the second result when I googled "php read barcode"?

https://github.com/mkoppanen/php-zbarcode

ETA: stop up-voting this. I suggested the exact library OP can't use.

0

u/AEWExcalibur Oct 13 '23

Did you not see the Dependencies section?

This is precisely what I was talking about. I can not figure out how to install said dependencies on my shared web hosting. I’m pretty certain I can’t.

So either some idea how to do that or an alternative

3

u/[deleted] Oct 13 '23

Oh, sorry, my bad. Didn't check as you referred to trying a "program" and assumed you meant something outside PHP.

0

u/[deleted] Oct 13 '23

[deleted]

1

u/AEWExcalibur Oct 13 '23

Yeah I think so Just kinda cba to move my website and database to another host I’d rather spend 50 weeks trying to work around that for each issue I face Then repeat the process again when/if I need something else

0

u/[deleted] Oct 13 '23

[deleted]

2

u/[deleted] Oct 13 '23

This is the dependency OP can't install, it's an external binary.

http://zbar.sourceforge.net/

2

u/[deleted] Oct 13 '23 edited Oct 13 '23

Do you have a web-like front-end you could decode the barcode on before it gets to the server?

https://github.com/ericblade/quagga2

2

u/RandyHoward Oct 13 '23

Do you care much about browser/device support? There is a limited and experimental browser API available, see here. I've never used it, can't say if or how well it works, but worth a shot if your audience is mostly mobile and you aren't too concerned with full support in all devices/browsers.