Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.5

Request #5047 GD driver addition: applyBorderImage() function
Submitted: 2005-08-09 23:12 UTC
From: norbert Assigned:
Status: Open Package: Image_Transform
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2005-08-09 23:12 UTC] norbert
Description: ------------ class Image_Transform_Driver_GD extends Image_Transform { /** * Apply a border image around the image * * @param int $borderhandle Handle of the loaded border image * @param int $padding_left Left margin of the current image on the border * @param int $padding_right Top margin of the current image on the border * @author Norbert Mocsnik * @return bool TRUE * @access public */ function applyBorderImage($borderhandle, $padding_left, $padding_right) { $this->new_x = imagesx($borderhandle); $this->new_y = imagesy($borderhandle); $new_img = $this->_createImage($this->new_x, $this->new_y, $this->true_color); ImageCopy($new_img, $borderhandle, 0, 0, 0, 0, $this->new_x, $this->new_y); ImageCopy($new_img, $this->imageHandle, $padding_left, $padding_right, 0, 0, $this->img_x, $this->img_y); $this->imageHandle = $new_img; $this->resized = true; return true; } Test script: --------------- I wanted to suggest to insert this into the manual but we currently don't have documentation for Image_Transform. I don't know the correct PHPDoc syntax to paste this as an example: $borderimage = Image_Transform::factory('GD'); $borderimage->load('mygraphicborder.jpg'); $imgtr = Image_Transform::factory('GD'); $imgtr->load('tmp/uploaded_image.jpg'); $imgtr->applyBorderImage($borderimage->imageHandle, 7, 7); $imgtr->save('uploads/image_with_border.jpg', '', 90);

Comments

 [2005-08-10 09:46 UTC] reywob
Thanks for this Norbert. Just a quick note for when we roll it into the code: it would be better for $borderhandle to be the object rather than $obj->imageHandle - that exposes too much of the messy internals (and would break if I ever rename that variable inline with the naming standards)
 [2005-08-10 10:57 UTC] norbert
Thank you for reviewing the code. I'm fine with passing Image_Transform objects directly but this introduces a limitation: users cannot pass their images created without Image_Transform. Since I don't need to pass such images, the decision is yours.
 [2005-08-10 14:09 UTC] jausions
The reason you'd need to pass the object itself, is that if you change backend engine, your code won't break. Not all drivers have an imageHandle property. So, yes, you would need to use Image_Transform, as you actually did in your example.