Solved

pdf to png conversion in Ghostscript or Imagemagick

Posted on 2008-10-01
1
2,159 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
ID: 22621649
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video, we show how to perform Bates Numbering/Stamping of PDF documents using Power PDF Advanced, the newest product from the Document Imaging division of Nuance Communications. There are two editions of Power PDF — Standard and Advanced. Th…
This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…

910 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

24 Experts available now in Live!

Get 1:1 Help Now