Create custom image effect

Public
</> CopyGet raw version
php
  1. /**
  2.  * Implements hook_image_effect_info()
  3.  */
  4. function my_module_image_effect_info() {
  5. $effects = array();
  6. $effects['blue_filter'] = array(
  7. 'label' => t('Blue filter'),
  8. 'effect callback' => 'my_module_blue_filter_image_effect'
  9. );
  10. return $effects;
  11. }
</> CopyGet raw version
php
  1. /**
  2.  * Callback function for blue_filter image effect
  3.  */
  4. function my_module_blue_filter_image_effect(&$image, $data) {
  5. if (!my_module_image_blue_filter($image)) {
  6. watchdog('image', 'he image %file could not be colorize because the imagefilter() function is not available in this PHP installation.', array('%file' => $image->source), WATCHDOG_ERROR);
  7. return FALSE;
  8. }
  9. return TRUE;
  10. }
</> CopyGet raw version
php
  1. /**
  2.  * Filter effect function
  3.  */
  4. function my_module_image_blue_filter(stdClass $image) {
  5. // Set colorization arguments
  6. $red_value = 26;
  7. $green_value = 87;
  8. $blue_value = 255;
  9. $alpha_value = 0;
  10. return imagefilter($image->resource, IMG_FILTER_COLORIZE, $red_value, $green_value, $blue_value, $alpha_value);
  11. }