Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

pdf to png conversion in Ghostscript or Imagemagick

Posted on 2008-10-01
1
Medium Priority
?
2,181 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 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
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.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

704 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