robbiepaul / zbar-qrdecoder

A PHP wrapper for Zbar. Decodes images/photos containing QR codes.
32 stars 38 forks source link

getting Bad arguments while using the package #1

Closed dhrubo001 closed 9 years ago

dhrubo001 commented 9 years ago

Controller

public function getDecode(){

        $image = Input::file('image');
        $name = $image->getClientOriginalName();
        $path = $image->getRealPath();

        $result = ZbarDecoder::make($image);
        echo $result; // Outputs the decoded text
        echo $result->format;

}
robbiepaul commented 9 years ago

The make method only accepts the full file path.

So for your example you could do this:

public function getDecode(){
    $image = Input::file('image');
    $name = $image->getClientOriginalName();
    $path = $image->getRealPath();

    $result = ZbarDecoder::make($path); // accepts the full path
    echo $result; // Outputs the decoded text
    echo $result->format;
}
dhrubo001 commented 9 years ago

Sorry Bro, but still getting the error

$process = $this->processBuilder->getProcess(); try { $process->mustRun(); $this->result = new Result($process->getOutput()); } catch (ProcessFailedException $e) { switch($e->getProcess()->getExitCode()) { case 1: throw new \Exception('Bad arguments'); break; case 2:

dhrubo001 commented 9 years ago

Now my code is

public function getDecode(){

        $image = Input::file('image');
        $name = $image->getClientOriginalName();
        $path = $image->getRealPath();

        $result = ZbarDecoder::make($path);
        echo $result; // Outputs the decoded text
        echo $result->format;
}
robbiepaul commented 9 years ago

I've just tried your exact code and it's working for me.

The 'Bad arguments' exit code 1 actually comes from zbarimg

If you see their documentation: http://linux.die.net/man/1/zbarimg

An error occurred while processing some image(s). This includes bad arguments, I/O errors and image handling errors from ImageMagick.

I would check you have ImageMagick installed correctly and it has read access to your tmp folder

robbiepaul commented 9 years ago

Also if you have access to the command line / ssh. Try the calling zbarimg to see if it works:

zbarimg -D <filepath>
dhrubo001 commented 9 years ago

Thank for your replies,

But friend can you provide me a complete zip of your code, that would be a real help. As i need a solution fast..

Thank YOu

robbiepaul commented 9 years ago

There's no point me zipping my code as I'm using the same code as you posted and it works.

I made a couple of changes to the code recently, so run a composer update see if that helps. If it still doesn't work please provide more information about your code envirnoment.

dhrubo001 commented 9 years ago

OK Thank you BRO...i will let you know soon