1. Home >
  2. Apps >
  3. Groups >

Code to resolve captcha and resolve barcode data from 2 different images using php

Question asked by Nayan Goenka in #PHP on Aug 4, 2013
Nayan Goenka
Nayan Goenka · Aug 4, 2013
Rank B1 - LEADER
Hey i m writing a code to resolve captcha and resolve barcode data from 2 different images using php. the images that needs to be resolved is in the same directory as the code. But the code isnt fetching it. Anyone any help on this function? The part of code which fetches the image is below.

public function setImage($img = "php_captcha")
        {
                if(!$this->LoadImage($img.".png")) echo "Image has not been found";
        }
Its appreciated if anyone can help on this function. this one works for my other codes but here i m a bit confused. If you need full code I will post it if asked for. Posted in: #PHP
Manish Goyal
Manish Goyal · Aug 5, 2013
Rank A2 - PRO
Can you post definition of $this->LoadImage()?
Nayan Goenka
Nayan Goenka · Aug 5, 2013
Rank B1 - LEADER
its default
Manish Goyal
Manish Goyal · Aug 5, 2013
Rank A2 - PRO
Impossible

There is no such function in php named loadImage

Assuming it is following OOps, check it's parent class
Nayan Goenka
Nayan Goenka · Aug 5, 2013
Rank B1 - LEADER
ohhh abt that function:

This is it

private function LoadImage($img)
        {
                if (file_exists($img))
                {
                                $image_info = getimagesize($img);
                                $image_size = explode("\"", $image_info[3]);
                                $this->image_width = $image_size[1];
                                $this->image_height = $image_size[3];
                                $this->img = imagecreatefrompng($img);
                             
                                return true;
                }
                else
                {
                                return false;
                }     
        }
Manish Goyal
Manish Goyal · Aug 5, 2013
Rank A2 - PRO
The function seems correct
This function assumes, image file path as it's argument
Did you check if the path is correct or not?
Nayan Goenka
Nayan Goenka · Aug 6, 2013
Rank B1 - LEADER
checked everything. Funny thing is, the program is running now, but gives an unusual warning now.

Image has not been found
Notice: Undefined offset: 1 in C:\xampp\htdocs\PHP\prog11.php on line 115
No Characters have been detected
Manish Goyal
Manish Goyal · Aug 6, 2013
Rank A2 - PRO
The problem is with this chunk of code

$image_size = explode("\"", $image_info[3]);
GetImageSize returns an array, you can't explode it

Simply remove this line and make it following

$image_info = getimagesize($img);
$this->image_width = $image_size[1];
$this->image_height = $image_size[3];
Please check whether it is 1st or 2nd is width

Thanks
Nayan Goenka
Nayan Goenka · Aug 6, 2013
Rank B1 - LEADER
goyal420
The problem is with this chunk of code

$image_size = explode("\"", $image_info[3]);
GetImageSize returns an array, you can't explode it

Simply remove this line and make it following

$image_info = getimagesize($img);
$this->image_width = $image_size[1];
$this->image_height = $image_size[3];
Please check whether it is 1st or 2nd is width

Thanks



Thanks for the try but it didnt work out with your code.

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up