function_exists

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Return true if the given function has been defined
function_exists(string $function): bool
    public function execute($image)

    {

        if (!
function_exists('exif_read_data')) {

            throw new 
NotSupportedException(

                
"Reading Exif data is not supported by this PHP installation."

            
);
    public function execute($image)

    {

        if ( ! 
function_exists('iptcparse')) {

            throw new 
NotSupportedException(

                
"Reading Iptc data is not supported by this PHP installation."

            
);
            case 'image/webp':

            case 
'image/x-webp':

                if ( ! 
function_exists('imagecreatefromwebp')) {

                    throw new 
NotReadableException(

                        
"Unsupported image type. GD/PHP installation does not support WebP format."

                    
);
            case 'image/x-win-bitmap':

            case 
'image/x-windows-bmp':

            case 
'image/x-xbitmap':

                if (! 
function_exists('imagecreatefrombmp')) {

                    throw new 
NotReadableException(

                        
"Unsupported image type. GD/PHP installation does not support BMP format."

                    
);
    protected function coreAvailable()

    {

        return (
extension_loaded('gd') && function_exists('gd_info'));

    }
    protected function processWebp()

    {

        if ( ! 
function_exists('imagewebp')) {

            throw new 
NotSupportedException(

                
"Webp format is not supported by PHP installation."

            
);
    protected function processBmp()

    {

        if ( ! 
function_exists('imagebmp')) {

            throw new 
NotSupportedException(

                
"BMP format is not supported by PHP installation."

            
);
    private function checkRequirements()

    {

        if ( ! 
function_exists('finfo_buffer')) {

            throw new 
MissingDependencyException(

                
"PHP Fileinfo extension must be installed/enabled to use Intervention Image."

            
);
    public function execute($image)

    {

        if (
$this->preferExtension && function_exists('exif_read_data')) {

            return 
parent::execute($image);

        }
        $mime finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data);

        
$length strlen($data);



        if (
function_exists('app') && is_a($app app(), 'Illuminate\Foundation\Application')) {



            
$response IlluminateResponse::make($data);

            
$response->header('Content-Type'$mime);
    public function testProcessWebpGd()

    {

        if (
function_exists('imagewebp')) {

            
$core imagecreatefromjpeg(__DIR__.'/images/test.jpg');

            
$encoder = new GdEncoder;

            
$image Mockery::mock('\Intervention\Image\Image');
    

    
public function testProcessWebpGdWithUnSupportedPalette()

    {

        if (
function_exists('imagewebp')) {

            
$core imagecreatefrompng(__DIR__.'/images/black-friday.png');

            
$encoder = new GdEncoder;

            
$image Mockery::mock('\Intervention\Image\Image');
    public function testProcessBmpGd()

    {

        if (
function_exists('imagebmp')) {

            
$core imagecreatefromjpeg(__DIR__.'/images/test.jpg');

            
$encoder = new GdEncoder;

            
$image Mockery::mock('\Intervention\Image\Image');
    public function testMakeFromWebp()

    {

        if (
function_exists('imagecreatefromwebp')) {

            
$img $this->manager()->make('tests/images/test.webp');

            
$this->assertInstanceOf('Intervention\Image\Image'$img);

            
$this->assertInternalType('resource'$img->getCore());
    public function testEncodeWebp()

    {

        if (
function_exists('imagewebp')) {

            
$img $this->manager()->make('tests/images/trim.png');

            
$data = (string) $img->encode('webp');

            
$this->assertEquals('image/webp; charset=binary'$this->getMime($data));