function image_save
7.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
Related topics
4 calls to image_save()
- file_validate_image_resolution in drupal-7.x/
includes/ file.inc - Verifies that image dimensions are within the specified maximum and minimum.
- ImageToolkitGdTestCase::testManipulations in drupal-7.x/
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 drupal-7.x/
modules/ simpletest/ tests/ image.test - Test the image_save() function.
- image_style_create_derivative in drupal-7.x/
modules/ image/ image.module - Creates a new image derivative based on an image style.
File
- drupal-7.x/
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;
}