My code:
$pdf = $this->name;
$saveAsPath = $this->path;
$img = new \Imagick($pdf);
$img->setResolution(300, 300);
$num_pages = $img->getNumberImages();
$img->setImageCompressionQuality(100);
for ($i = 0; $i < $num_pages; $i++) {
$img->setIteratorIndex($i);
$img->setImageFormat('jpeg');
$img->writeImage($saveAsPath . '/' . $i.'.jpg');
}
$img->destroy();
Results:
Original file:
After Imagick:
As we can see lines and letters are worse. How can I improve the quality?