function textimage_image_add_margin in Textimage 7.2
Same name and namespace in other branches
- 5.2 textimage.module \textimage_image_add_margin()
- 5 textimage.module \textimage_image_add_margin()
- 6.2 textimage.module \textimage_image_add_margin()
This function adds a margin (or border) around an existing image resource.
1 call to textimage_image_add_margin()
- textimage_image_from_preset in ./
textimage.module - Loads the Textimage preset and generates the GD image resource.
File
- ./
textimage.utils.inc, line 325 - Utility routines of Textimage.
Code
function textimage_image_add_margin($img, $margin) {
$width = imagesx($img);
$height = imagesy($img);
// Create a new image for the background.
$back_img = imagecreatetruecolor($width + $margin['right'] + $margin['left'], $height + $margin['top'] + $margin['bottom']);
$back = imagecolorallocatealpha($back_img, 0, 0, 0, 127);
imagefill($back_img, 0, 0, $back);
// Apply the source image ontop the background with the new margin.
imagecopy($back_img, $img, $margin['left'], $margin['top'], 0, 0, $width, $height);
imagealphablending($back_img, TRUE);
imagesavealpha($back_img, TRUE);
return $back_img;
}