image_gd_close

Definition

image_gd_close($res, $destination, $extension)
includes/image.gd.inc, line 204

Description

GD helper to write an image resource to a destination file.

Parameters

$res An image resource created with image_gd_open().

$destination A string file path where the iamge should be saved.

$extension A string containing one of the following extensions: gif, jpg, jpeg, png.

Return value

Boolean indicating success.

Related topics

Namesort iconDescription
Image toolkitsDrupal's image toolkits provide an abstraction layer for common image file manipulations like scaling, cropping, and rotating. The abstraction frees module authors from the need to support multiple image libraries, and it allows site...

Code

<?php
function image_gd_close($res, $destination, $extension) {
  $extension = str_replace('jpg', 'jpeg', $extension);
  $close_func = 'image'. $extension;
  if (!function_exists($close_func)) {
    return FALSE;
  }
  if ($extension == 'jpeg') {
    return $close_func($res, $destination, variable_get('image_jpeg_quality', 75));
  }
  else {
    return $close_func($res, $destination);
  }
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.