# Merge Images in PHP

> Merge multiple images into a single PNG image in PHP with Aspose.Slides for PHP via Java.

Source: https://products.aspose.com/slides/php-java/merger/image-to-image/
Updated: 2026-07-20



## Merge Images using Aspose.Slides

[**Aspose.Slides for PHP via Java**](/slides/php-java/) lets you place images in a custom layout on a presentation slide and render the composed slide as a single image. The example below combines two source images side by side and saves the result as PNG.

## Merge Images in PHP

Load the source files with `Images::fromFile`, add them to the slide with `addPictureFrame`, render the slide with `getImage`, and save the result with `ImageFormat::Png`.

### PHP code for merging images

```php
$presentation = new Presentation();
try {
    $slide = $presentation->getSlides()->get_Item(0);

    $firstSourceImage = Images::fromFile("image1.png");
    try {
        $firstPresentationImage = $presentation->getImages()->addImage($firstSourceImage);
    } finally {
        $firstSourceImage->dispose();
    }

    $secondSourceImage = Images::fromFile("image2.jpg");
    try {
        $secondPresentationImage = $presentation->getImages()->addImage($secondSourceImage);
    } finally {
        $secondSourceImage->dispose();
    }

    $slide->getShapes()->addPictureFrame(
        ShapeType::Rectangle, 0, 0, 360, 270, $firstPresentationImage);
    $slide->getShapes()->addPictureFrame(
        ShapeType::Rectangle, 360, 0, 360, 270, $secondPresentationImage);

    $slideImage = $slide->getImage(1.0, 1.0);
    try {
        $slideImage->save("merged-image.png", ImageFormat::Png);
    } finally {
        $slideImage->dispose();
    }
} finally {
    $presentation->dispose();
}
```

## How to merge images in PHP

Install **Aspose.Slides for PHP via Java**. See [**Installation**](https://docs.aspose.com/slides/php-java/installation/).

Configure Aspose.Slides in your PHP project.

Create a `Presentation` and access its first slide through a variable.

Load the source images with `Images::fromFile` and place them on the slide with `addPictureFrame`.

Render the slide with `getImage` and save the result with `ImageFormat::Png`.

## Merge Other Files
