PHP Imagick - PDF to Png conversion comes with a strike line

Viewed 156

I have the following code in my server where it converts PDF to PNG image.

$pdf_url = 'new_ecg.pdf';
$image = new Imagick($pdf_url);
$count = $image->getNumberImages();
$images_array = array();
if($count){
    $image_obj = new Imagick();
    $image_obj->readImage($pdf_url);
    $image_obj->resetIterator();
    # Combine multiple images into one, stacked vertically.
    $appendedimage = $image_obj->appendImages(true);
    $appendedimage = $appendedimage->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
    $appendedimage->setImageFormat("png");
    file_put_contents ('op.png', $appendedimage);
}

It actually worked so far well and gave the output needed. Recently it is generating PNG with a line in it and i am unable to figure out why it is happening. Please see the following line.

A cross line appearing on the converted image

It still works well with the old PDF conversions. But the new PDF is making this issue. I tried this new PDF in a online PDF to PNG converter and it converts without the line that appears on my conversion. So there is no error with PDF as well !

I have attached the PDF as well as outputs in the following link...

https://transfernow.net/1817q2g23dg6

Can someone help me finding where it goes wrong with above program ?

0 Answers
Related