PDF to -jpg convertion , the image breaks for multiple PDF
Posted: 2016-04-14T04:28:26-07:00
Version: ImageMagick-6.9.2-0
We have deveopers who is using a linux server on amazon AWS.
We want to convert PDF to .jpg for presentation.
It works fine for most PDF´s, but when we upload a PDF with multiple pages, the conversion breaks.
The settings I have for the "convert" part are:
$max_width = '842';
$max_height = '595';
//$attachments_array = array();
//exec("convert -density 300 -trim ".$attachment_path." -quality 30 ".$pdfImgPath);
//exec("convert -version -density -1 ".$attachment_path." -quality 100 ".$pdfImgPath);
//exec("convert -density 1080 -set units PixelsPerInch -density 1080 -quality 300 -background white -flatten -resize {$max_width}x{$max_height} ".$attachment_path." ".$pdfImgPath);
exec("convert -density 1080 -set units PixelsPerInch -density 152 -quality 100 -background white -flatten -resize {$max_width}x{$max_height} ".$attachment_path." ".$pdfImgPath);
// iterate over pages of the pdf file
The pdf itself is created in PPT, and in landscape mode, and I guess the resolution for A4 landscape is 842x595 using 72 dpi.
I have tried to increase quality to 100, to make the image crisp.
and the second density to 152.
When uploading a PDF from 23Kb to 8Mb it all works fine.
but when a small PDF is creted with multiple "pages" the upload breaks.
We have deveopers who is using a linux server on amazon AWS.
We want to convert PDF to .jpg for presentation.
It works fine for most PDF´s, but when we upload a PDF with multiple pages, the conversion breaks.
The settings I have for the "convert" part are:
$max_width = '842';
$max_height = '595';
//$attachments_array = array();
//exec("convert -density 300 -trim ".$attachment_path." -quality 30 ".$pdfImgPath);
//exec("convert -version -density -1 ".$attachment_path." -quality 100 ".$pdfImgPath);
//exec("convert -density 1080 -set units PixelsPerInch -density 1080 -quality 300 -background white -flatten -resize {$max_width}x{$max_height} ".$attachment_path." ".$pdfImgPath);
exec("convert -density 1080 -set units PixelsPerInch -density 152 -quality 100 -background white -flatten -resize {$max_width}x{$max_height} ".$attachment_path." ".$pdfImgPath);
// iterate over pages of the pdf file
The pdf itself is created in PPT, and in landscape mode, and I guess the resolution for A4 landscape is 842x595 using 72 dpi.
I have tried to increase quality to 100, to make the image crisp.
and the second density to 152.
When uploading a PDF from 23Kb to 8Mb it all works fine.
but when a small PDF is creted with multiple "pages" the upload breaks.