Ravi Sharma
Ravi Sharma

Reputation: 1182

Imagemagick remove the upper content while converting pdf to image

My pdf first page looks like :

enter image description here

When I run below command:

exec("convert -density 300 $pdf_path $temp_images 2>&1",$output);

It converts its page in image that looks like:

enter image description here

this thing happen only when the dimensions of pdf are width- 595 and height- 842.

Any suggestion will be appreciated.

Upvotes: 1

Views: 236

Answers (2)

Ravi Sharma
Ravi Sharma

Reputation: 1182

This code solve my problem but I want this in command line

$im = new Imagick();
$im->readImage( $pdf_path );
$im->setImageFormat( "jpg" );
$im->writeImage( $temp_images );
echo 'Image Converted';

Upvotes: 1

KenS
KenS

Reputation: 31139

Looks like the CropBox of the PDF is being used instead of the media size, or possibly ImageMagick is sending a fixed (incorrect, Letter) media size to Ghostscript in order to render the page.

Unfortunately that's about all I know regarding ImageMagick, you need someone who can tell you how to find and alter the Ghostscript invocation.

Upvotes: 1

Related Questions