# Convert HTML to JPG in PHP

> Convert HTML content to JPG images in PHP with Aspose.Slides for PHP via Java.

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



## Convert HTML to JPG in PHP

[**Aspose.Slides for PHP via Java**](/slides/php-java/) can import HTML content into presentation slides and render those slides as JPG images. The example below exports every generated slide to a separate JPG file.

Aspose.Slides provides a straightforward API for HTML-to-JPG conversion and can also export the imported content to PDF, PowerPoint, and other supported formats.

## Convert HTML to JPG using PHP

To convert HTML content to JPG, create a `Presentation`, import the HTML with `addFromHtml`, and render each generated slide.

### PHP code for converting HTML into JPG

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

    $htmlContent = file_get_contents("input.html");
    $slides->addFromHtml($htmlContent);

    $slideCount = java_values($slides->size());
    for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
        $slide = $slides->get_Item($slideIndex);
        $slideImage = $slide->getImage(1, 1);

        try {
            $filePath = "slide_" . ($slideIndex + 1) . ".jpg";
            $slideImage->save($filePath, ImageFormat::Jpeg);
        } finally {
            $slideImage->dispose();
        }
    }
} finally {
    $presentation->dispose();
}
```

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

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

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

Configure Aspose.Slides in your PHP project.

Read the HTML content with `file_get_contents` and pass it to `addFromHtml`.

Render each slide with `getImage` and save it with `ImageFormat::Jpeg`.

## Convert HTML To Other Supported Formats

- [HTML TO IMAGE](/slides/php-java/conversion/html-to-image/)
- [HTML TO PDF](/slides/php-java/conversion/html-to-pdf/)
- [HTML TO PPT](/slides/php-java/conversion/html-to-ppt/)
- [HTML TO PPTX](/slides/php-java/conversion/html-to-pptx/)
- [HTML TO PNG](/slides/php-java/conversion/html-to-png/)
- [HTML TO TIFF](/slides/php-java/conversion/html-to-tiff/)
- [HTML TO XML](/slides/php-java/conversion/html-to-xml/)
