Redis and Predis configuration for Drupal 7

Install redis module (http://drupal.org/project/redis) and put https://github.com/nrk/predis into ‘sites/all/libraries’ and put these settings into settings.php file

 

define('PREDIS_BASE_PATH', DRUPAL_ROOT . '/sites/all/libraries/predis-0.8/lib/');

$conf['redis_client_interface']  = 'Predis';
$conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc';
$conf['cache_class_cache'] = 'Redis_Cache';
$conf['cache_class_cache_form'] = 'Redis_Cache';
$conf['cache_class_cache_views'] = 'Redis_Cache';
$conf['cache_class_cache_page'] = 'Redis_Cache';
$conf['cache_class_cache_menu'] = 'Redis_Cache';
$conf['cache_class_cache_path'] = 'Redis_Cache';
$conf['cache_class_cache_entity_node'] = 'Redis_Cache';
$conf['cache_class_cache_entity_taxonomy_term'] = 'Redis_Cache';
$conf['cache_class_cache_entity_taxonomy_vocabulary'] = 'Redis_Cache';
$conf['cache_class_cache_entity_file'] = 'Redis_Cache';
$conf['cache_class_cache_entity_user'] = 'Redis_Cache';
$conf['cache_class_cache_filter'] = 'Redis_Cache';
$conf['cache_class_cache_admin_menu'] = 'Redis_Cache';
$conf['cache_class_cache_bootstrap'] = 'Redis_Cache';
$conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';
$conf['redis_client_base'] = 1;
$conf['cache_class_cache_field'] = 'Redis_Cache';

Scale and crop image programmatically in Drupal 7

// Load image file entity.
$file = file_load($fid);

// Load image by uri.
$image = image_load($file->uri);

// Use Drupal's scale and crop function to do the work for you.
image_scale_and_crop($image, $scale['width'], $scale['height']);

// Save image to file, you don't need to save the file entity.
image_save($image);