1.20.x image.inc image_save(stdClass $image, $destination = NULL)

Closes the image and saves the changes to a file.

Parameters

$image: An image object returned by image_load(). 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 on success, FALSE on failure.:

See also

image_load()

image_gd_save()

Related topics

File

includes/image.inc, line 437
API for manipulating images.

Code

function image_save(stdClass $image, $destination = NULL) {
  if (empty($destination)) {
    $destination = $image->source;
  }
  if ($return = image_toolkit_invoke('save', $image, array($destination))) {
    // Clear the cached file size and refresh the image information.
    clearstatcache();
    $image->info = image_get_info($destination, $image->toolkit);

    if (backdrop_chmod($destination)) {
      return $return;
    }
  }
  return FALSE;
}