Skip to content

Commit

Permalink
add boundary param to insert method
Browse files Browse the repository at this point in the history
  • Loading branch information
antonlukin committed Mar 31, 2024
1 parent 179f840 commit 4555b45
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "antonlukin/poster-editor",
"version": "5.12",
"version": "5.13",
"description": "Wrapper for PHP's GD Library for easy image manipulation",
"keywords": ["php", "image", "text", "gd"],
"homepage": "https://github.com/antonlukin/poster-editor",
Expand Down
28 changes: 17 additions & 11 deletions src/PosterEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @package PosterEditor
* @author Anton Lukin <anton@lukin.me>
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @version Release: 5.12
* @version Release: 5.13
* @link https://github.com/antonlukin/poster-editor
*/
class PosterEditor
Expand Down Expand Up @@ -124,12 +124,13 @@ public function make($data)
*
* Paste a given image source over the current image with an optional position.
*
* @param string $data Binary data or path to file or another class instance.
* @param array $options List of x/y relative offset coords from top left corner. Default: centered.
* @param string $data Binary data or path to file or another class instance.
* @param array $options List of x/y relative offset coords from top left corner. Default: centered.
* @param array $boundary Optional. Actual dimensions of the drawn image.
*
* @return $this
*/
public function insert($data, $options = array())
public function insert($data, $options = array(), &$boundary = array())
{
$defaults = array(
'x' => null,
Expand Down Expand Up @@ -158,6 +159,13 @@ public function insert($data, $options = array())
imagecopyresampled($this->resource, $source, $options['x'], $options['y'], 0, 0, $width, $height, $width, $height);
imagedestroy($source);

$boundary = array(
'x' => $options['x'],
'y' => $options['y'],
'width' => $width,
'height' => $height,
);

return $this;
}

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

// Set default boundary vaules.
$boundary = array_merge(
array(
'x' => $options['x'],
'y' => $options['y'],
'width' => 0,
'height' => 0,
)
$boundary = array(
'x' => $options['x'],
'y' => $options['y'],
'width' => 0,
'height' => 0,
);

foreach ($lines as $index => $line) {
Expand Down

0 comments on commit 4555b45

Please sign in to comment.