Fork me on GitHub

insert — Paste over another image

Description

public Intervention\Image\Image insert(mixed $source, [string $position, [integer $x, integer $y]])

Paste a given image source over the current image with an optional position and a offset coordinate. This method can be used to apply another image as watermark because the transparency values are maintained.

Parameters

source

The image source that will inserted on top of the current image. The method can handle the following types of input:

position (optional)

Set a position where image will be inserted. For example if you are setting the anchor to bottom-left the image will be positioned at the bottom-left border of the current image. The position of the new image will be calculated relatively to this location.

The possible values are:

x (optional)

Optional relative offset of the new image on x-axis of the current image. Offset will be calculated relative to the position parameter. Default: 0

y (optional)

Optional relative offset of the new image on y-axis of the current image. Offset will be calculated relative to the position parameter. Default: 0

Return Values

Instance of Intervention\Image\Image

Examples

// create new Intervention Image
$img = Image::make('public/foo.jpg');

// paste another image
$img->insert('public/bar.png');

// create a new Image instance for inserting
$watermark = Image::make('public/watermark.png');
$img->insert($watermark, 'center');

// insert watermark at bottom-right corner with 10px offset
$img->insert('public/watermark.png', 'bottom-right', 10, 10);

See also