Powerpoint PPT for JPG or PNG Convert Images Using PHP

I need to convert slides / files with one PowerPoint (PPT) to JPG or PNG format on linux, but have not yet found a way to do this successfully. I heard that this can be done with an open office through php, but have not found examples or a lot of useful documentation. I would think about doing this with python or java, but I'm not sure which route to take.

I understand that this can be done using COM on a Windows server, but I would like to refrain from this, if possible.

Any ideas / pointers gratefully received. (And yes, I searched the site and others before posting!)

Thanks in advance,

Rob Gunley

+4
source share
2 answers

Quick response (2 steps):

## First converts your presentation to PDF unoconv -f pdf presentation.ppt ## Then convert your PDF to jpg convert presentation.pdf presentation_%03d.jpg 

And the will.

The explanation is a bit more:

I already adhered to the same need. Convert a PowerPoint slide set to an image set. I did not find a single tool for this. But I found unoconv that converts libreoffice formats to other formats, including jpg, png and PDF. The only drawback is that unoconv only converts one slide to a jpg / png file, but when converted to PDF, it converts the entire presentation into a multi-page PDF file. Thus, answare converted PPT to PDF and converted imagemagick, converted several PDF pages into a set of images.

Unoconv Distributed in Ubuntu Distribution

 apt-get install unoconv 

And the conversion is distributed with the imagemagick package

 apt-get install imagemagick 

There is a post on my blog about this.

+13
source

This can be done with PHP using the 3d batch library (Aspose.Slides). It will work on both .ppt and .pptx, and it is lightning fast.

Here is the corresponding code snippet in PHP:

 $runtime->RegisterAssemblyFromFile("libraries/_bin/aspose/Aspose.Slides.dll", "Aspose.Slides"); $runtime->RegisterAssemblyFromFullQualifiedName("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing"); $sourcefile = "D:\\MYPRESENTATION.ppt"; $presentation = $runtime->TypeFromName("Aspose.Slides.Presentation")->Instantiate($sourcefile); $format = $runtime->TypeFromName("System.Drawing.Imaging.ImageFormat")->Png; $x = 0; /** @var \NetPhp\Core\NetProxyCollection */ $slides = $presentation->Slides->AsIterator(); foreach ($slides as $slide) { $bitmap = $slide->GetThumbnail(1, 1); $destinationfile ="d:\\output\\slide_{$x++}.png"; $bitmap->Save($destinationfile, $format); } $presentation->Dispose(); 

It does not use Office Interop (which is NOT recommended for server-side automation) and quickly performs highlighting.

You can control the output format, image size and quality. You actually get a .Net Bitmap object so you can do whatever you want with it.

The original post is here:

http://www.drupalonwindows.com/en/blog/powerpoint-presentation-images-php-drupal-example

0
source

Source: https://habr.com/ru/post/1399567/


All Articles