D
D
devilsD2018-05-16 12:42:40
PHP
devilsD, 2018-05-16 12:42:40

Why do images disappear after converting pdf to jpg, only text remains in the output?

Converting the first page of a PDF file to JPG using ImageMagick. I use this link https://github.com/spatie/pdf-to-image

public function convert($source)
{

    $pdf = new Pdf($source);
    $pdf->setPage(1)
    ->setCompressionQuality(50)
    ->setOutputFormat($this->format)
    ->saveImage($this->getSavePath($source));
    return $this->getUrl($source);
}

Everything works on the local server and on the test server, but on production it only converts text. In those places where there were photos in the document, the output is empty areas.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Sundukov, 2018-05-16
@alekciy

The experience of using this library speaks of slow work. Try to use the gs script directly like this: https://github.com/alekciy/pdf2image/blob/7f8856dc...
In general, I can offer a ready-made conversion service. Based on Yii2, see README.md for deployment description . If you don’t need a code, but quickly convert a PDF, then I have a deployed project in the form of a ready-made service. If necessary, write in a personal.

V
Valery, 2018-05-16
@it_monk

The problem may be in the old version of ImageMagick on the server. Try to execute on the server from the console
. If .jpg is the same without pictures, then this is the problem and you just need to update ImageMagick

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question