Convert PNG to PPTX in PHP
Place a PNG image on a slide and save the result as a PowerPoint PPTX file with Aspose.Slides for PHP via Java.
Convert PNG to PPTX using PHP
Create a Presentation, load the PNG with Images::fromFile, match the slide size to the image with setSize, add the image with addPictureFrame, and call save with SaveFormat::Pptx.
PHP code for converting PNG into PPTX
$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());
$presentation->getSlideSize()->setSize(
$imageWidth, $imageHeight, SlideSizeScaleType::DoNotScale);
$slide->getShapes()->addPictureFrame(
ShapeType::Rectangle, 0, 0, $imageWidth, $imageHeight, $embeddedImage);
$presentation->save("output.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}Convert PNG to PPTX in PHP
Aspose.Slides for PHP via Java lets you place a PNG image on a presentation slide at its original dimensions and save the result as a PowerPoint Open XML presentation.
The PNG is stored as an image on the slide, so the presentation remains editable while the original raster image content is preserved.
How to convert PNG to PPTX using Aspose.Slides for PHP API
These are the steps to convert PNG to PPTX in PHP.
- Install Aspose.Slides for PHP via Java.
- Create a
Presentation, access its first slide, and load the PNG withImages::fromFile. - Set the slide dimensions with
setSize, then place the image on the slide withaddPictureFrame. - Call
savewith the output file path andSaveFormat::Pptx.
Built with Aspose.Slides
Convert PNG to PPTX 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 PPTX.
- 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: