function image_save
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
Related topics
4 calls to image_save()
- file_validate_image_resolution in includes/
file.inc - Verifies 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.
File
-
includes/
image.inc, line 417
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.