使用PHP和ImageMagick将PDF转换为JPG时的低分辨率文本

I have use this code to convert PDF file to JPEG images

$im = new Imagick();
$im->setResolution(90,90);
$im->readImage($pdf_file);
$im->setImageFormat('jpeg');
$im->writeImages($save_to,false);
$im->clear(); 
$im->destroy();

and it work but I have a problem that when there is a text with white background it will not be clear but I don't have this problem when ever I have colored BG.

this image will make every thing clear enter image description here

JPEG compression generates such artefacts on edges where there is big color differences (such as between your black text and your white background). Try to to push up the compression quality or use another image format for images containing text (such as png)

Add this functions:

$im = new Imagick();
$im->setResolution(90,90);

if ($width < 300) $im->sharpenImage(4, 1);
$im->setCompression(Imagick::COMPRESSION_JPEG);
$im->setCompressionQuality(100); // or some alse 

$im->readImage($pdf_file);
$im->setImageFormat('jpeg');
$im->writeImages($save_to,false);
$im->clear(); 
$im->destroy();