Solved

pdf to png conversion in Ghostscript or Imagemagick

Posted on 2008-10-01
1
2,153 Views
Last Modified: 2013-12-13
I use siteground as my host.  They tell me ghostscript is loaded and the absolute path to the binary executable is "/usr/bin/ghostscript".  They also tell me imagemagick is loaded and the path to the binary is "/usr/bin/".    

What I need is a sample php script that allows me to convert XXX.pdf to XXX.png on the server using one of these two tools.  Siteground is proving useless in supplying me with any samples even though they told me they had some when I signed up.

Has anyone ever done this?
0
Comment
Question by:mysmartypants2
1 Comment
 
LVL 7

Accepted Solution

by:
ljubiccica earned 500 total points
Comment Utility
Hey there!

If everything is configured right you should be able to use this:

<?php
$file1 = "filename.pdf";
$file2 = "filename.jpg";

$result1 = @exec("gs -q -dNOPAUSE -dBATCH -sDEVICE=png16m -sOutputFile=$file2 $file1 2>&1");
?>

If it doesn't work you may try with abolute paths like:

$result1 = @exec("sw/bin/gs -q -dNOPAUSE -dBATCH -sDEVICE=jpeg
-sOutputFile=$file2 $file1 2>&1");

Hope it will work for you,
ljubiccica
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In a previous article here at Experts Exchange (http://www.experts-exchange.com/articles/18414/Create-a-PDF-file-with-Contact-Sheets-montage-of-thumbnails-for-all-JPG-files-in-a-folder-and-each-of-its-subfolders-using-an-automated-batch-method.html)…
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
We often encounter PDF files that are pure images, that is, they do not have text characters, but instead contain only raster graphics. The most common causes of this are document scanning software and faxing software/services that create image-only…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now