src/Gregwar/Captcha/CaptchaBuilder.php
protected function validateBackgroundImage($backgroundImage)
    {
        // check if file exists
        if (!file_exists($backgroundImage)) {
            $backgroundImageExploded = explode('/', $backgroundImage);
            $imageFileName = count($backgroundImageExploded) > 1? $backgroundImageExploded[count($backgroundImageExploded)-1] : $backgroundImage;

            throw new Exception('Invalid background image: ' . $imageFileName);
        }

        // check image type
        $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
        $imageType = finfo_file($finfo, $backgroundImage);
        finfo_close($finfo);

        if (!in_array($imageType, $this->allowedBackgroundImageTypes)) {
            throw new Exception('Invalid background image type! Allowed types are: ' . join(', ', $this->allowedBackgroundImageTypes));
        }

        return $imageType;
    }
protected function validateBackgroundImage($backgroundImage)
    {
        // check if file exists
        if (!file_exists($backgroundImage)) {
            $backgroundImageExploded = explode('/', $backgroundImage);
            $imageFileName = count($backgroundImageExploded) > 1? $backgroundImageExploded[count($backgroundImageExploded)-1] : $backgroundImage;

            throw new Exception('Invalid background image: ' . $imageFileName);
        }

        // check image type
        $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
        $imageType = finfo_file($finfo, $backgroundImage);
        finfo_close($finfo);

        if (!in_array($imageType, $this->allowedBackgroundImageTypes)) {
            throw new Exception('Invalid background image type! Allowed types are: ' . join(', ', $this->allowedBackgroundImageTypes));
        }

        return $imageType;
    }
protected function validateBackgroundImage ( $ backgroundImage ) { // check if file exists if ( ! file_exists ( $ backgroundImage ) ) { $ backgroundImageExploded = explode ( '/' , $ backgroundImage ) ; $ imageFileName = count ( $ backgroundImageExploded ) > 1 ? $ backgroundImageExploded [ count ( $ backgroundImageExploded ) - 1 ] : $ backgroundImage ; throw new Exception ( 'Invalid background image: ' . $ imageFileName ) ; } // check image type $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; // return mime type ala mimetype extension $ imageType = finfo_file ( $ finfo , $ backgroundImage ) ; finfo_close ( $ finfo ) ; if ( ! in_array ( $ imageType , $ this -> allowedBackgroundImageTypes ) ) { throw new Exception ( 'Invalid background image type! Allowed types are: ' . join ( ', ' , $ this -> allowedBackgroundImageTypes ) ) ; } return $ imageType ; }
Validate the background image path. Return the image type if valid

@param string $backgroundImage
@return string
@throws Exception
Validate the background image path . Return the image type if valid