You are here

function image_animgif_save in Animated gif support for image styles 7

Helper to write an image resource to a destination file.

Actually it just moves the generated animgif to the proper place, beacuse the GD uses imagegd() which is not proper there, it losts the animation.

File

./animgif_support.module, line 333
Provides animated gif resizing support for the image styles.

Code

function image_animgif_save(stdClass $image, $destination) {
  $scheme = file_uri_scheme($destination);
  $return = FALSE;

  // Work around lack of stream wrapper support in imagejpeg() and imagepng().
  $local_wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_LOCAL);
  if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
    if (isset($local_wrappers[$scheme])) {

      // Convert stream wrapper URI to normal path.
      $destination = drupal_realpath($destination);
    }
  }
  if (!empty($image->info['resized_animgif_uri'])) {
    $image->uri = $image->info['resized_animgif_uri'];
    $return = file_unmanaged_move($image->info['resized_animgif_uri'], $destination, FILE_EXISTS_REPLACE);
  }
  return $return;
}