Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

pdf to png conversion in Ghostscript or Imagemagick

Posted on 2008-10-01
1
Medium Priority
?
2,186 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 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