You are here

function _imagick_process_frames in Imagick 7

Helper function to process all image frames

Parameters

$image:

$function:

Return value

mixed

4 calls to _imagick_process_frames()
image_imagick_crop in effects/imagick.crop.inc
Crop an image using the Imagick toolkit.
image_imagick_desaturate in effects/imagick.desaturate.inc
Convert an image resource to grayscale.
image_imagick_resize in effects/imagick.resize.inc
Scale an image to the specified size using Imagick.
image_imagick_rotate in effects/imagick.rotate.inc
Rotate an image the given number of degrees.

File

./imagick.module, line 748
Imagick toolkit for image manipulation within Drupal.

Code

function _imagick_process_frames($image, $function, $args = []) {

  // Get the image resource
  $res =& $image->resource;

  // Remove first argument, this is the image object
  array_shift($args);
  if (function_exists($function)) {
    if ($image->info['mime_type'] == 'image/gif') {

      // Get each frame in the GIF
      $res = $res
        ->coalesceImages();
      do {
        $result = call_user_func_array($function, array_merge([
          $res,
        ], $args));
      } while ($result && $res
        ->nextImage());
      $res = $res
        ->deconstructImages();
      return $result;
    }
    else {
      return call_user_func_array($function, array_merge([
        $res,
      ], $args));
    }
  }
}