gd_info example


  public function getMimeType() {
    return $this->getType() ? image_type_to_mime_type($this->getType()) : '';
  }

  /** * {@inheritdoc} */
  public function getRequirements() {
    $requirements = [];

    $info = gd_info();
    $requirements['version'] = [
      'title' => $this->t('GD library'),
      'value' => $info['GD Version'],
    ];

    // Check if toolkit supported image formats can be actually processed by the     // GD library installed with PHP.     $check_formats = [
      IMG_GIF => 'GIF',
      IMG_JPG => 'JPEG',
      IMG_PNG => 'PNG',
      
return $this;
    }

    /** * Get GD version * * @return mixed */
    public function getVersion()
    {
        if (function_exists('gd_info')) {
            $gdVersion = @gd_info();

            return preg_replace('/\D/', '', $gdVersion['GD Version']);
        }

        return false;
    }

    /** * Resizes the image. * * @return GDHandler */
return false;
    }

    /** * Checks the gd version * * @return bool|string */
    private function checkGd()
    {
        if (\function_exists('gd_info')) {
            $gd = gd_info();
            if (preg_match('#[0-9.]+#', $gd['GD Version']$match)) {
                if (substr_count($match[0], '.') == 1) {
                    $match[0] .= '.0';
                }

                return $match[0];
            }

            return $gd['GD Version'];
        }

        
return false;
    }

    /** * Checks the gd version * * @return bool|string */
    private function checkGd()
    {
        if (\function_exists('gd_info')) {
            $gd = gd_info();
            if (preg_match('#[0-9.]+#', $gd['GD Version']$match)) {
                if (substr_count($match[0], '.') == 1) {
                    $match[0] .= '.0';
                }

                return $match[0];
            }

            return $gd['GD Version'];
        }

        


            $info['wp-media']['fields']['imagemagick_file_formats'] = array(
                'label' => __( 'ImageMagick supported file formats' ),
                'value' => ( empty( $formats ) ) ? __( 'Unable to determine' ) : implode( ', ', $formats ),
                'debug' => ( empty( $formats ) ) ? 'Unable to determine' : implode( ', ', $formats ),
            );
        }

        // Get GD information, if available.         if ( function_exists( 'gd_info' ) ) {
            $gd = gd_info();
        } else {
            $gd = false;
        }

        $info['wp-media']['fields']['gd_version'] = array(
            'label' => __( 'GD version' ),
            'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
            'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
        );

        $gd_image_formats     = array();
        
// Try perform a missing toolkit operation.     $this->assertFalse($image->apply('missing_op', []), 'Calling a missing image toolkit operation plugin should fail, but it did not.');
  }

  /** * @covers ::getRequirements */
  public function testGetRequirements(): void {
    $this->assertEquals([
      'version' => [
        'title' => t('GD library'),
        'value' => gd_info()['GD Version'],
        'description' => t("Supported image file formats: %formats.", [
          '%formats' => implode(', ', ['GIF', 'JPEG', 'PNG', 'WEBP']),
        ]),
      ],
    ]$this->imageFactory->get()->getToolkit()->getRequirements());
  }

}
'multisite_enabled'  => $multisite_enabled,
        'initial_db_version' => get_site_option( 'initial_db_version' ),
        'extensions'         => array_combine( $extensionsarray_map( 'phpversion', $extensions ) ),
        'platform_flags'     => array(
            'os'   => PHP_OS,
            'bits' => PHP_INT_SIZE === 4 ? 32 : 64,
        ),
        'image_support'      => array(),
    );

    if ( function_exists( 'gd_info' ) ) {
        $gd_info = gd_info();
        // Filter to supported values.         $gd_info = array_filter( $gd_info );

        // Add data for GD WebP and AVIF support.         $query['image_support']['gd'] = array_keys(
            array_filter(
                array(
                    'webp' => isset( $gd_info['WebP Support'] ),
                    'avif' => isset( $gd_info['AVIF Support'] ),
                )
            )
        );
Home | Imprint | This part of the site doesn't use cookies.