function image_save

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 417
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 (drupal_chmod($destination)) {
      return $return;
    }
  }
  return FALSE;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!image.inc/function/image_save/7.x