[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/imageapi/ -> imageapi_gd.install (source)

   1  <?php
   2  
   3  function imageapi_gd_requirements($phase) {
   4    $requirements = array();
   5    $t = get_t();
   6  
   7    $gd = function_exists('imagegd2');
   8  
   9    if (!$gd) {
  10      $requirements['imageapi_gd'] = array(
  11        'title' =>  $t('GD library'),
  12        'value' => $t('Not installed'),
  13        'severity' => REQUIREMENT_ERROR,
  14        'description' => $t('The GD library for PHP is missing or outdated. Please check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/en/image.setup.php')),
  15      );
  16      return $requirements;
  17    }
  18  
  19    // If color module hasn't already do so, report the version.
  20    if (!module_exists('color')) {
  21      $info = gd_info();
  22      $requirements['imageapi_gd'] = array(
  23        'title' =>  $t('GD library'),
  24        'value' => $info['GD Version'],
  25        'severity' => REQUIREMENT_OK,
  26      );
  27    }
  28  
  29    // Check image format support
  30    foreach (array('gif', 'jpeg', 'png') as $format) {
  31      if (function_exists('imagecreatefrom'. $format)) continue;
  32      $requirements['imageapi_gd_'. $format] = array(
  33        'title' => $t('GD !format Support', array('!format' => drupal_ucfirst($format))),
  34        'value' => $t('Not installed'),
  35        'severity' => REQUIREMENT_ERROR,
  36        'description' => $t('PHP GD was not compiled with %format support.', array('%format' => $format)),
  37      );
  38    }
  39  
  40  
  41    // check non required stuff aka not installation blockers.
  42    if ($phase == 'runtime') {
  43      if (!function_exists('imagerotate')) {
  44        $requirements['imageapi_gd_imagerotate'] = array(
  45          'title' => $t('GD Image Rotation'),
  46          'value' => $t('Low Quality / Poor Performance'),
  47          'severity' => REQUIREMENT_WARNING,
  48          'description' => $t('The installed version of PHP GD does not support image rotations. It was probably compiled using the official GD libraries from <a href="http://www.libgd.org">http://www.libgd.org</a> instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See <a href="http://www.php.net/manual/en/image.setup.php">PHP Manual</a> for more information. A slower implementation of imagerotate() written in PHP will used in the interim.'),
  49        );
  50      }
  51  
  52      if (!function_exists('imagefilter')) {
  53        $requirements['imageapi_gd_imagefilter'] = array(
  54          'title' => $t('GD Image Filtering'),
  55          'value' => $t('Low Quality / Poor Performance'),
  56          'severity' => REQUIREMENT_WARNING,
  57          'description' => $t('The installed version of PHP GD does not support image filtering(desaturate, blur, negate, etc). It was probably compiled using the official GD libraries from <a href="http://www.libgd.org">http://www.libgd.org</a> instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See <a href="http://www.php.net/manual/en/image.setup.php">PHP Manual</a> for more information. A slower implementation of imagefilter() written in PHP will be used in the interim.'),
  58        );
  59      }
  60  
  61      // Test the 'memory_limit' PHP configuration directive
  62      $memory_limit = ini_get('memory_limit');
  63  
  64      // If $memory_limit contains a value of -1, the PHP runtime
  65      // doesn't impose a limit on memory used by PHP scripts
  66      if ($memory_limit && $memory_limit != -1 && parse_size($memory_limit) < parse_size('96M')) {
  67        $requirements['imagecache_memory_limit'] = array(
  68          'title' => $t('ImageAPI GD Memory Limit'),
  69          'value' => $memory_limit,
  70          'severity' => REQUIREMENT_WARNING,
  71          'description' => $t('It is highly recommended that you set you PHP memory_limit to 96M to use ImageAPI GD. A 1600x1200 images consumes ~45M of memory when decompressed and there are instances where ImageAPI GD is operating on two decompressed images at once.'),
  72        );
  73      }
  74  
  75    }
  76    return $requirements;
  77  }
  78  
  79  /**
  80   * Implementation of hook_uninstall().
  81   */
  82  function imageapi_gd_uninstall() {
  83    variable_del('imageapi_jpeg_quality');
  84  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7