lib/blobfolio/common/image.php
public static function has_webp($cwebp=null, $gif2webp=null) {
		// Gotta set it first?
		if (null === static::$_webp_gd) {
			$image_types = \imagetypes();
			static::$_webp_gd = (
				(0 !== ($image_types & \IMG_WEBP)) &&
				\function_exists('imagewebp') &&
				\function_exists('imagecreatefromwebp')
			);
		}

		// See if this system supports the binary method. In general
		// we'll just check this once, but if a previous check failed
		// and binary paths are supplied, we'll check again.
		if (
			(null === static::$_webp_binary) ||
			(
				(false === static::$_webp_binary) &&
				$cwebp &&
				$gif2webp
			)
		) {
			static::$_webp_binary = false;

			// We're using proc_open() to handle execution; if this is
			// missing or disabled, we're done.
			if (\function_exists('proc_open') && \is_callable('proc_open')) {
				// Resolve the binary paths.
				if (null === $cwebp) {
					$cwebp = constants::CWEBP;
				}
				else {
					$cwebp = (string) $cwebp;
				}
				if (null === $gif2webp) {
					$gif2webp = constants::GIF2WEBP;
				}
				else {
					$gif2webp = (string) $gif2webp;
				}

				ref\file::path($cwebp, true);
				ref\file::path($gif2webp, true);

				if (
					$cwebp &&
					$gif2webp &&
					@\is_file($cwebp) &&
					@\is_executable($cwebp) &&
					@\is_file($gif2webp) &&
					@\is_executable($gif2webp)
				) {
					static::$_webp_binary = array(
						'cwebp'=>$cwebp,
						'gif2webp'=>$gif2webp,
					);
				}
			}
		}

		return (static::$_webp_gd || (false !== static::$_webp_binary));
	}
public static function has_webp($cwebp=null, $gif2webp=null) {
		// Gotta set it first?
		if (null === static::$_webp_gd) {
			$image_types = \imagetypes();
			static::$_webp_gd = (
				(0 !== ($image_types & \IMG_WEBP)) &&
				\function_exists('imagewebp') &&
				\function_exists('imagecreatefromwebp')
			);
		}

		// See if this system supports the binary method. In general
		// we'll just check this once, but if a previous check failed
		// and binary paths are supplied, we'll check again.
		if (
			(null === static::$_webp_binary) ||
			(
				(false === static::$_webp_binary) &&
				$cwebp &&
				$gif2webp
			)
		) {
			static::$_webp_binary = false;

			// We're using proc_open() to handle execution; if this is
			// missing or disabled, we're done.
			if (\function_exists('proc_open') && \is_callable('proc_open')) {
				// Resolve the binary paths.
				if (null === $cwebp) {
					$cwebp = constants::CWEBP;
				}
				else {
					$cwebp = (string) $cwebp;
				}
				if (null === $gif2webp) {
					$gif2webp = constants::GIF2WEBP;
				}
				else {
					$gif2webp = (string) $gif2webp;
				}

				ref\file::path($cwebp, true);
				ref\file::path($gif2webp, true);

				if (
					$cwebp &&
					$gif2webp &&
					@\is_file($cwebp) &&
					@\is_executable($cwebp) &&
					@\is_file($gif2webp) &&
					@\is_executable($gif2webp)
				) {
					static::$_webp_binary = array(
						'cwebp'=>$cwebp,
						'gif2webp'=>$gif2webp,
					);
				}
			}
		}

		return (static::$_webp_gd || (false !== static::$_webp_binary));
	}
public static function has_webp ( $ cwebp = null , $ gif2webp = null ) { // Gotta set it first? if ( null === static :: $ _webp_gd ) { $ image_types = \ imagetypes ( ) ; static :: $ _webp_gd = ( ( 0 !== ( $ image_types & \ IMG_WEBP ) ) && \ function_exists ( 'imagewebp' ) && \ function_exists ( 'imagecreatefromwebp' ) ) ; } // See if this system supports the binary method. In general // we'll just check this once, but if a previous check failed // and binary paths are supplied, we'll check again. if ( ( null === static :: $ _webp_binary ) || ( ( false === static :: $ _webp_binary ) && $ cwebp && $ gif2webp ) ) { static :: $ _webp_binary = false ; // We're using proc_open() to handle execution; if this is // missing or disabled, we're done. if ( \ function_exists ( 'proc_open' ) && \ is_callable ( 'proc_open' ) ) { // Resolve the binary paths. if ( null === $ cwebp ) { $ cwebp = constants :: CWEBP ; } else { $ cwebp = ( string ) $ cwebp ; } if ( null === $ gif2webp ) { $ gif2webp = constants :: GIF2WEBP ; } else { $ gif2webp = ( string ) $ gif2webp ; } ref \ file :: path ( $ cwebp , true ) ; ref \ file :: path ( $ gif2webp , true ) ; if ( $ cwebp && $ gif2webp && @ \ is_file ( $ cwebp ) && @ \ is_executable ( $ cwebp ) && @ \ is_file ( $ gif2webp ) && @ \ is_executable ( $ gif2webp ) ) { static :: $ _webp_binary = array ( 'cwebp' => $ cwebp , 'gif2webp' => $ gif2webp , ) ; } } } return ( static :: $ _webp_gd || ( false !== static :: $ _webp_binary ) ) ; }
Check Probable WebP Support

This attempts to check whether PHP natively supports WebP, or
if maybe third-party binaries are installed on the system.

@param string $cwebp Path to cwebp.
@param string $gif2webp Path to gif2webp.
@return bool True/false.
Check Probable WebP Support