| 1 |
<?php
|
| 2 |
// $Id: imageapi_gd.install,v 1.9 2009/03/11 05:42:47 drewish Exp $
|
| 3 |
|
| 4 |
function imageapi_gd_requirements($phase) {
|
| 5 |
$requirements = array();
|
| 6 |
$t = get_t();
|
| 7 |
|
| 8 |
$gd = function_exists('imagegd2');
|
| 9 |
|
| 10 |
if (!$gd) {
|
| 11 |
$requirements['imageapi_gd'] = array(
|
| 12 |
'title' => $t('GD library'),
|
| 13 |
'value' => $t('Not installed'),
|
| 14 |
'severity' => REQUIREMENT_ERROR,
|
| 15 |
'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')),
|
| 16 |
);
|
| 17 |
return $requirements;
|
| 18 |
}
|
| 19 |
|
| 20 |
// report version.
|
| 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 |
// Check image format support
|
| 29 |
foreach (array('gif', 'jpeg', 'png') as $format) {
|
| 30 |
if (function_exists('imagecreatefrom'. $format)) continue;
|
| 31 |
$requirements['imageapi_gd_'. $format] = array(
|
| 32 |
'title' => $t('GD !format Support', array('!format' => drupal_ucfirst($format))),
|
| 33 |
'value' => $t('Not installed'),
|
| 34 |
'severity' => REQUIREMENT_ERROR,
|
| 35 |
'description' => $t('PHP GD was not compiled with %format support.', array('%format' => $format)),
|
| 36 |
);
|
| 37 |
}
|
| 38 |
|
| 39 |
|
| 40 |
// check non required stuff aka not installation blockers.
|
| 41 |
if ($phase == 'runtime') {
|
| 42 |
if (!function_exists('imagerotate')) {
|
| 43 |
$requirements['imageapi_gd_imagerotate'] = array(
|
| 44 |
'title' => $t('GD Image Rotation'),
|
| 45 |
'value' => $t('Low Quality / Poor Performance'),
|
| 46 |
'severity' => REQUIREMENT_WARNING,
|
| 47 |
'description' => $t('The installed version of PHP GD does not support image rotations. It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See: @url. An implementation of imagerotate in PHP will used in the interim.', array('@url' => 'http://www.php.net/manual/en/image.setup.php')),
|
| 48 |
);
|
| 49 |
}
|
| 50 |
|
| 51 |
if (!function_exists('imagefilter')) {
|
| 52 |
$requirements['imageapi_gd_imagefilter'] = array(
|
| 53 |
'title' => $t('GD Image Filtering'),
|
| 54 |
'value' => $t('Low Quality / Poor Performance'),
|
| 55 |
'severity' => REQUIREMENT_WARNING,
|
| 56 |
'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 http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See @url. An implementation of imagefilter in PHP will be used in the interim.', array('@url' => 'http://www.php.net/manual/en/image.setup.php')),
|
| 57 |
);
|
| 58 |
}
|
| 59 |
|
| 60 |
// Test the 'memory_limit' PHP configuration directive
|
| 61 |
$memory_limit = ini_get('memory_limit');
|
| 62 |
|
| 63 |
// If $memory_limit contains a value of -1, the PHP runtime
|
| 64 |
// doesn't impose a limit on memory used by PHP scripts
|
| 65 |
if ($memory_limit && $memory_limit != -1 && parse_size($memory_limit) < parse_size('96M')) {
|
| 66 |
$requirements['imagecache_memory_limit'] = array(
|
| 67 |
'title' => $t('ImageAPI GD Memory Limit'),
|
| 68 |
'value' => $memory_limit,
|
| 69 |
'severity' => REQUIREMENT_WARNING,
|
| 70 |
'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.'),
|
| 71 |
);
|
| 72 |
}
|
| 73 |
|
| 74 |
}
|
| 75 |
return $requirements;
|
| 76 |
}
|
| 77 |
|
| 78 |
/**
|
| 79 |
* Remove the old JPEG quality setting.
|
| 80 |
*/
|
| 81 |
function imageapi_gd_update_7000() {
|
| 82 |
variable_del('imageapi_jpeg_quality');
|
| 83 |
return array();
|
| 84 |
}
|
| 85 |
|