Cheetah
InsertCommand.php
Go to the documentation of this file.
1 <?php
2 
4 
6 {
13  public function execute($image)
14  {
15  $source = $this->argument(0)->required()->value();
16  $position = $this->argument(1)->type('string')->value();
17  $x = $this->argument(2)->type('digit')->value(0);
18  $y = $this->argument(3)->type('digit')->value(0);
19 
20  // build watermark
21  $watermark = $image->getDriver()->init($source);
22 
23  // define insertion point
24  $image_size = $image->getSize()->align($position, $x, $y);
25  $watermark_size = $watermark->getSize()->align($position);
26  $target = $image_size->relativePosition($watermark_size);
27 
28  // insert image at position
29  imagealphablending($image->getCore(), true);
30  return imagecopy($image->getCore(), $watermark->getCore(), $target->x, $target->y, 0, 0, $watermark_size->width, $watermark_size->height);
31  }
32 }
Intervention\Image\Gd\Commands
Definition: BackupCommand.php:3
php
Intervention\Image\Gd\Commands\InsertCommand
Definition: InsertCommand.php:6
Intervention\Image\Gd\Commands\InsertCommand\execute
execute($image)
Definition: InsertCommand.php:13
Intervention\Image\Commands\AbstractCommand\argument
argument($key)
Definition: AbstractCommand.php:45
Intervention\Image\Commands\AbstractCommand
Definition: AbstractCommand.php:6