Generate Thumbnails with PHP for a wide range of file formats

Go To


I have had a client request on a upload facility for his clients, but after upload that a image thumbnail to be created.

All normal images are ok but he his talking about .psd, .pdf, .eps, .ppt

Having a good look around I think wih imagemagick & ghostscript will cater for most of these but I cant find a solution of PPT or EPS.

Im hoping that imagemagick will be able to do eps as it can do a psd.

Any suggestion on EPS or PPT file format.

Thank you if you can advice.

2009-06-16 09:22
by Lee


I'm late to the party I know, however...

This is what I use for .PDF, .EPS and .AI thumbnailing. (Assuming all necessary ImageMagick distros installed)

$file = '';

$cache = $_SERVER['DOCUMENT_ROOT'].'/cache/';//ensure dir is writeable

$ext = "jpg";//just the extension

$dest = $cache.$file.'.'.$ext;

if (file_exists($dest)){
    $img = new imagick();
    header( "Content-Type: image/jpg" );
    echo $img;

 } else {

    $img = new imagick($_SERVER['DOCUMENT_ROOT'].'/'.$file.'[0]');

    $width = $img->getImageheight();
    //$img->cropImage($width, $width, 0, 0);
    $img->scaleImage(105, 149, true);


    header( "Content-Type: image/jpg" );
    echo $img;

Don't know why it works, but it does - One code to rule them all right?

2013-11-02 12:48
by myshadowself


PPT is a powerpoint presentation. So creating an image that is a PPT would require some library that can pull this off.

Here are some resources to help you out.

EPS is a vector format, so not unless you have your image as vector objects, you wont be able to do this correctly.

2009-06-16 10:53
by Ólafur Waage


Just some thoughts - none of these things has been tested by myself.


You should be able to convert your EPS to a PDF with ghostscript. Using imagemagick & ghostscript you can convert the PDF to some bitmap format (GIF, PNG or JPG).


This seems to be somehow more complicated. If your are on a Windows machine you could resort to use the Powerpoint API from within a small hand-written converter. Another possibility would perhaps be to use Apache POI-HSLF whichs is a Java API to the Powerpoint file format. This would require a Java program for the conversion process. The last resort could be that study the Powerpoint binary file format and see if there is e.g. a thumbnail embedded (perhaps beeing used for the file icon in Windows Explorer) that could be extracted.

2009-06-16 11:30
by Stefan Gehrig


You could find some free icon sets and use a default icon for all .ppt file and another for all .eps. You can then further extend this for all file formats that cannot be converted to a image, such as audio files. Not the perfect solution but something a user may feel more comfortable with then just having text.

2009-06-16 17:44
by Tao Zhyn