Merge SVG to PNG in PHP

High-speed and cross-platform PHP library for merging SVG to PNG images using PHP code

Merge SVG to PNG using Aspose.Slides

Aspose.Slides for PHP via Java is a powerful PHP library used to merge and manipulate presentations, images, and other files. When you merge SVG to PNG, you are effectively combining SVG images to get a PNG picture.

Merge SVG to PNG in PHP

Using Aspose.Slides for PHP via Java , you can merge SVG to PNG files quickly with just a few lines of code

PHP code for merging SVG to PNG


<?php
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");

$pres = new Presentation();
try
{
    $slide = $pres->getSlides()->get_Item(0);
    
    $svgImage1 = new SvgImage('image1.svg');
    $image1 = $pres->getImages()->addImage($svgImage1);
    $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 0, 0, 360, 540, $image1);
    
    $svgImage2 = new SvgImage('image2.svg');
    $image2 = $pres->getImages()->addImage($svgImage2);
    $slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 360, 0, 360, 540, $image2);
    

    $img = $pres->getSlides()->get_Item(0)->getThumbnail(2, 2);
    $imageio = new Java("javax.imageio.ImageIO");
    $javafile = new Java("java.io.File", "merged-image.png");
    $imageio->write($img, "PNG", $javafile);
}
finally
{
    if ($pres != null) $pres->dispose();
}
?>

How to merge SVG to PNG in PHP

  1. Install Aspose.Slides for PHP via Java. See Installation .

  2. Add the library as a reference in your project.

  3. Create an instance of the Presentation class.

  4. Load the SVG files you want to merge together.

  5. Save the resulting PNG image.

Merge PDF Files Online

How to Merge PDF in Python

Merge other files

You can also combine files in other formats to get a single file