Skip to content

Commit 4555b45

Browse files
committed
add boundary param to insert method
1 parent 179f840 commit 4555b45

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "antonlukin/poster-editor",
3-
"version": "5.12",
3+
"version": "5.13",
44
"description": "Wrapper for PHP's GD Library for easy image manipulation",
55
"keywords": ["php", "image", "text", "gd"],
66
"homepage": "https://github.com/antonlukin/poster-editor",

src/PosterEditor.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* @package PosterEditor
2424
* @author Anton Lukin <anton@lukin.me>
2525
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
26-
* @version Release: 5.12
26+
* @version Release: 5.13
2727
* @link https://github.com/antonlukin/poster-editor
2828
*/
2929
class PosterEditor
@@ -124,12 +124,13 @@ public function make($data)
124124
*
125125
* Paste a given image source over the current image with an optional position.
126126
*
127-
* @param string $data Binary data or path to file or another class instance.
128-
* @param array $options List of x/y relative offset coords from top left corner. Default: centered.
127+
* @param string $data Binary data or path to file or another class instance.
128+
* @param array $options List of x/y relative offset coords from top left corner. Default: centered.
129+
* @param array $boundary Optional. Actual dimensions of the drawn image.
129130
*
130131
* @return $this
131132
*/
132-
public function insert($data, $options = array())
133+
public function insert($data, $options = array(), &$boundary = array())
133134
{
134135
$defaults = array(
135136
'x' => null,
@@ -158,6 +159,13 @@ public function insert($data, $options = array())
158159
imagecopyresampled($this->resource, $source, $options['x'], $options['y'], 0, 0, $width, $height, $width, $height);
159160
imagedestroy($source);
160161

162+
$boundary = array(
163+
'x' => $options['x'],
164+
'y' => $options['y'],
165+
'width' => $width,
166+
'height' => $height,
167+
);
168+
161169
return $this;
162170
}
163171

@@ -774,13 +782,11 @@ public function text($text, $options = array(), &$boundary = array())
774782
$lines = explode(PHP_EOL, $text);
775783

776784
// Set default boundary vaules.
777-
$boundary = array_merge(
778-
array(
779-
'x' => $options['x'],
780-
'y' => $options['y'],
781-
'width' => 0,
782-
'height' => 0,
783-
)
785+
$boundary = array(
786+
'x' => $options['x'],
787+
'y' => $options['y'],
788+
'width' => 0,
789+
'height' => 0,
784790
);
785791

786792
foreach ($lines as $index => $line) {

0 commit comments

Comments
 (0)