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

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.

Replies

  • Manish Goyal
    Manish Goyal
    Can you post definition of $this->LoadImage()?
  • Nayan Goenka
    Nayan Goenka
    its default
  • Manish Goyal
    Manish Goyal
    Impossible

    There is no such function in php named loadImage

    Assuming it is following OOps, check it's parent class
  • Nayan Goenka
    Nayan Goenka
    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
    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
    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
    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
    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 are reading an archived discussion.

Related Posts

Here are some tips on how to ask for a raise. Hazard: May get one thrown out on the back side instead. https://cr4.globalspec.com/blogentry...r-For-A-Salary-Or-Wage-Raise?frmtrk=cr4digest
Biomedical engineers from Drexel University, University Of Pennsylvania, Thomas Jefferson University and UCLA have identified a new type of cell in your brain that helps humans keep track of their...
Those of you planning to discard your landline connections - hold on! If you thought those old telephone lines are obsolete, then we've a news for you. Alcatel-Lucent has demonstrated...
WeChat version 5.0 has been launched. It may not be available in your country as of yet, but App Store in China seems to be the first in the lot...
Indian Railways will soon have the AC coaches powered by solar energy. The Integral Coach Factory at Chennai has joined hands with IIT Madras to design coaches that will use...