I’m trying to convert PDF to IMG (JPG) with help PHP.
I’m using imagick extension.
this is my code
$fp_pdf = fopen($pdf, 'rb');
$img = new imagick(); // [0] can be used to set page number
$img->readImageFile($fp_pdf);
$img->setImageFormat( "jpg" );
$img->setImageCompression(imagick::COMPRESSION_JPEG);
$img->setImageCompressionQuality(90);
$img->setResolution(300,300);
$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
$data = $img->getImageBlob();
my source pdf file has right dimension (210×297 mm, like A4 has). And everything looks good.
But my jpg has page dimension as 842×595 px, and DPI is 72.
and img file much more smaller on paper then pdf, when i had print it.
what is a proper way to make image file from pdf and make it so big as pdf (on paper)
ImageMagick uses GhostScript to process JPEGs, so you’d do better to
execGhostScript directly, which would be much more efficient and give you more control. It would also be only 1execstatement, instead of playing around with the IMagick functions.