# Convert PNG to HTML in PHP

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

Source: https://products.aspose.com/slides/php-java/conversion/png-to-html/
Updated: 2026-07-31



## Convert PNG to HTML in PHP

[**Aspose.Slides for PHP via Java**](/slides/php-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.

## 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

```php
$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();
}
```

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

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

Install [**Aspose.Slides for PHP via Java**](/slides/php-java/).

Create a `Presentation` and access its first slide.

Load the PNG with `Images::fromFile` and add it to the presentation image collection.

Add the image to the slide with `addPictureFrame`, then save with `SaveFormat::Html5`.

## Convert PNG To Other Supported Formats

- [PNG TO JPG](/slides/php-java/conversion/png-to-jpg/)
- [PNG TO PDF](/slides/php-java/conversion/png-to-pdf/)
- [PNG TO SVG](/slides/php-java/conversion/png-to-svg/)
- [PNG TO PPT](/slides/php-java/conversion/png-to-ppt/)
- [PNG TO PPTX](/slides/php-java/conversion/png-to-pptx/)
