1. drupal
    1. 8
    2. 7
8 – 7 image_save(stdClass $image, $destination = NULL)

Close the image and save the changes to a file.


$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 or FALSE, based on success.

See also



Related topics

▾ 4 functions call image_save()

file_validate_image_resolution in includes/
Verify that image dimensions are within the specified maximum and minimum.
ImageToolkitGdTestCase::testManipulations in modules/simpletest/tests/image.test
Since PHP can't visually check that our images have been manipulated properly, build a list of expected color values for each of the corners and the expected height and widths for the final images.
ImageToolkitUnitTest::testSave in modules/simpletest/tests/image.test
Test the image_save() function.
image_style_create_derivative in modules/image/image.module
Creates a new image derivative based on an image style.


includes/, line 387

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.
    $image->info = image_get_info($destination, $image->toolkit);

    if (drupal_chmod($destination)) {
      return $return;
  return FALSE;