Merge PNG Images in PHP
Arrange multiple PNG images on a slide and render them as one PNG image with Aspose.Slides for PHP via Java.
Merge PNG to PNG using Aspose.Slides
Aspose.Slides for PHP via Java lets you place multiple PNG images in a custom layout on a presentation slide and render the composed slide as a single PNG image.
Merge PNG to PNG 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 PNG to PNG
$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.png");
try {
$secondPresentationImage = $presentation->getImages()->addImage($secondSourceImage);
} finally {
$secondSourceImage->dispose();
}
$slide->getShapes()->addPictureFrame(
ShapeType::Rectangle, 0, 0, 360, 540, $firstPresentationImage);
$slide->getShapes()->addPictureFrame(
ShapeType::Rectangle, 360, 0, 360, 540, $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 PNG images in PHP
Follow these steps to merge multiple PNG images into one PNG image in PHP.
Install Aspose.Slides for PHP via Java. See Installation .
Configure Aspose.Slides in your PHP project.
Create a
Presentationinstance and access its first slide through a variable.Load the PNG images with
Images::fromFileand place them on the slide withaddPictureFrame.Render the slide with
getImageand save it withImageFormat::Png.
Merge Other Files
You can also combine files in other supported formats.