From 4ab53d145bec440529a6304f470eb952a40eec6b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 29 Dec 2008 23:25:28 +0000 Subject: Create Image::composite() and implement it in GD, ImageMagick and GraphicsMagick drivers. --- kohana/libraries/Image.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'kohana/libraries/Image.php') diff --git a/kohana/libraries/Image.php b/kohana/libraries/Image.php index bd723a27..6fcce090 100644 --- a/kohana/libraries/Image.php +++ b/kohana/libraries/Image.php @@ -254,6 +254,35 @@ class Image_Core { return $this; } + /** + * Overlay a second image on top of this one. + * + * @throws Kohana_Exception + * @param string $overlay_file path to an image file + * @param integer $x x offset for the overlay + * @param integer $y y offset for the overlay + * @param integer $transparency transparency percent + */ + public function composite($overlay_file, $x, $y, $transparency) + { + $image_info = getimagesize($overlay_file); + + // Check to make sure the image type is allowed + if ( ! isset(Image::$allowed_types[$image_info[2]])) + throw new Kohana_Exception('image.type_not_allowed', $overlay_file); + + $this->actions['composite'] = array + ( + 'overlay_file' => $overlay_file, + 'mime' => $image_info['mime'], + 'x' => $x, + 'y' => $y, + 'transparency' => $transparency + ); + + return $this; + } + /** * Flip an image horizontally or vertically. * -- cgit v1.2.3