You are here

function imageapi_image_close in ImageAPI 6

Same name and namespace in other branches
  1. 5 imageapi.module \imageapi_image_close()

Close the image and save the changes to a file.

Parameters

$image: An image object returned by imageapi_image_open(). The object's 'info' property will be updated if the file is saved successfully.

$destination: Destination path where the image should be saved. If it is empty the original image file will be overwritten.

Return value

TRUE or FALSE, based on success.

File

./imageapi.module, line 399
An ImageAPI supporting additional image plugins as modules. Images are treated as objects, and images are not written per manipulation as Drupal's core image handling works.

Code

function imageapi_image_close($image, $destination = NULL) {
  if (empty($destination)) {
    $destination = $image->source;
  }
  if ($return = imageapi_toolkit_invoke('close', $image, array(
    $destination,
  ))) {

    // Clear the cached file size and refresh the image information.
    clearstatcache();
    $image->info = image_get_info($destination);
    if (@chmod($destination, 0664)) {
      return $return;
    }
    watchdog('imageapi', 'Could not set permissions on destination file: %file', array(
      '%file' => $destination,
    ));
  }
  return FALSE;
}