Solved

pdf to png conversion in Ghostscript or Imagemagick

Posted on 2008-10-01
1
2,175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…

632 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