| Versionen | |
|---|---|
| drupal7 | image_gd_save(stdClass $image, $destination) |
GD helper to write an image resource to a destination file.
see image_save()
$image An image object.
$destination A string file path where the image should be saved.
$extension A string containing one of the following extensions: gif, jpg, jpeg, png.
TRUE or FALSE, based on success.
modules/
<?php
function image_gd_save(stdClass $image, $destination) {
$extension = str_replace('jpg', 'jpeg', $image->info['extension']);
$function = 'image' . $extension;
if (!function_exists($function)) {
return FALSE;
}
if ($extension == 'jpeg') {
return $function($image->resource, $destination, variable_get('image_jpeg_quality', 75));
}
else {
// Always save PNG images with full transparency.
if ($extension == 'png') {
imagealphablending($image->resource, FALSE);
imagesavealpha($image->resource, TRUE);
}
return $function($image->resource, $destination);
}
}
?>
Kommentare
Kommentar hinzufügen