Sorry, no results were found for this search.

You are viewing the documentation for Intervention Image v4. This version is in an early beta stage. Use stable in production environments.

Learn how to insert images onto other images using the Intervention Image library. Position images, adjust offsets, and control opacity for custom overlays or watermarks.

Insert Images

public Image::insert(mixed $image, int $x = 0, int $y = 0, string|Alignment $alignment = Alignment::TOP_LEFT, int $opacity = 100): ImageInterface

Inserts a new image on top of the current image. The image to be inserted can be specified from any of the supported image sources. Optionally you can pass coordinates for an offset to move the image relative to the specified alignment position. It is also possible to control the opacity of the insertion using the opacity parameter.

Parameters

Name Type Description
image mixed Source of the image to be placed
x int Optional relative offset of the new image on x-axis
y int Optional relative offset of the new image on y-axis
alignment string or Alignment Alignment position of the image to be placed
opacity int Control over the opacity of the placed image ranging from 0 (fully transparent) to 100 (opaque)

Example

use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\Alignment;

// create an test image from a file
$manager = ImageManager::usingDriver(Driver::class);
$image = $manager->decode('test.png');

// place another image
$image->insert('images/foo.png');

// create a new resized watermark instance and insert at bottom-right 
// corner with 10px offset and an opacity of 25%
$watermark = $manager->decode('watermark.png');
$image->insert(
    $watermark,
    10, 
    10,
    Alignment::BOTTOM_RIGHT, 
    25
);
Edit