Convert PNG to HTML in PHP

Place a PNG image on a presentation slide and export the presentation as HTML with Aspose.Slides for PHP via Java.

Convert PNG to HTML using PHP

Create a Presentation, load the PNG with Images::fromFile, add it to the first slide with addPictureFrame, and call save with SaveFormat::Html5.

PHP code for converting PNG into HTML

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

    $sourceImage = Images::fromFile("input.png");
    try {
        $embeddedImage = $presentation->getImages()->addImage($sourceImage);
    } finally {
        $sourceImage->dispose();
    }

    $imageWidth = java_values($embeddedImage->getWidth());
    $imageHeight = java_values($embeddedImage->getHeight());

    $slide->getShapes()->addPictureFrame(
        ShapeType::Rectangle, 0, 0, $imageWidth, $imageHeight, $embeddedImage);

    $presentation->save("output.html", SaveFormat::Html5);
} finally {
    $presentation->dispose();
}

Convert PNG to HTML in PHP

Aspose.Slides for PHP via Java lets you place a PNG image on a presentation slide at its original dimensions and export the result as HTML.

The PNG is embedded in the presentation, and the slide is exported with SaveFormat::Html5. The same workflow can be adapted to other supported image and presentation formats.

How to convert PNG to HTML using Aspose.Slides for PHP API

These are the steps to convert PNG to HTML in PHP.

  1. Install Aspose.Slides for PHP via Java.
  2. Create a Presentation and access its first slide.
  3. Load the PNG with Images::fromFile and add it to the presentation image collection.
  4. Add the image to the slide with addPictureFrame, then save with SaveFormat::Html5.

Built with Aspose.Slides

Convert PNG to HTML Online

The free Aspose.Slides Conversion app is built with Aspose.Slides for PHP via Java, the same API as the code above. Open it and see what the API can do with your own PNG files.

  • Runs in your browser, nothing to install.
  • See how Aspose.Slides converts files before you write code.
  • Upload PNG files and save them as HTML.
  • Download the result or convert more files.

Convert PNG To Other Supported Formats

You can also convert PNG and save to other file formats. See all supported formats below: