0

I need help to convert a PDF file to TIFF file, I do this with PHP and ImageMagick from Linux, like this

exec('convert -density 110 * -compress LZW out.tiff');

But this sometimes fail, so I need to know the best way to convert a PDF to a TIFF, without lost quality, or if someone knows a better way to do this.

Thanks.

pipook
  • 27
  • 1
  • 7
  • be aware of TIFF compression issue desribed here http://stackoverflow.com/questions/20880558/tiff-plot-generation-and-compression-r-vs-gimp-vs-irfanview-vs-photoshop-fil – Eugene Mar 02 '16 at 17:22
  • anyway, what is the error message you are getting? Check php logs to find what exactly the error is, if it is ImageMagick internal error or not enough memory to generate image. You may also try to use another lossless compression for TIFF output, like ZIP to see if it will work better for your files. – Eugene Mar 02 '16 at 17:24

1 Answers1

1

Try Ghostscript, here you have an example.

<?php

$outputTiff = "/var/www/html/document.tiff";
$inputPDF = "/var/www/html/document.pdf";

//Execute the ghost script that takes the PDF as an input and saves it as tiff.
$response = exec("gs -SDEVICE=tiffg4 -r600x600 -sPAPERSIZE=letter -sOutputFile=$outputTiff -dNOPAUSE -dBATCH  $inputPDF");

?>