Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Return true if the given function has been defined
<?php function_exists(string $function): bool
<?php public function execute($image)
{
if (!function_exists('exif_read_data')) {
throw new NotSupportedException(
"Reading Exif data is not supported by this PHP installation."
);
<?php public function execute($image)
{
if ( ! function_exists('iptcparse')) {
throw new NotSupportedException(
"Reading Iptc data is not supported by this PHP installation."
);
<?php 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."
);
<?php 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."
);
<?php protected function coreAvailable()
{
return (extension_loaded('gd') && function_exists('gd_info'));
}
<?php protected function processWebp()
{
if ( ! function_exists('imagewebp')) {
throw new NotSupportedException(
"Webp format is not supported by PHP installation."
);
<?php protected function processBmp()
{
if ( ! function_exists('imagebmp')) {
throw new NotSupportedException(
"BMP format is not supported by PHP installation."
);
<?php private function checkRequirements()
{
if ( ! function_exists('finfo_buffer')) {
throw new MissingDependencyException(
"PHP Fileinfo extension must be installed/enabled to use Intervention Image."
);
<?php public function execute($image)
{
if ($this->preferExtension && function_exists('exif_read_data')) {
return parent::execute($image);
}
<?php $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);
<?php public function testProcessWebpGd()
{
if (function_exists('imagewebp')) {
$core = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$encoder = new GdEncoder;
$image = Mockery::mock('\Intervention\Image\Image');
<?php
public function testProcessWebpGdWithUnSupportedPalette()
{
if (function_exists('imagewebp')) {
$core = imagecreatefrompng(__DIR__.'/images/black-friday.png');
$encoder = new GdEncoder;
$image = Mockery::mock('\Intervention\Image\Image');
<?php public function testProcessBmpGd()
{
if (function_exists('imagebmp')) {
$core = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$encoder = new GdEncoder;
$image = Mockery::mock('\Intervention\Image\Image');
<?php 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());
<?php 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));