<? function pdf2png($pdf, $path) { if (!extension_loaded('imagick')) { return false; } if (!file_exists($pdf)) { return false; } $im = new Imagick(); $im->setResolution(80, 80); //设置分辨率 值越大分辨率越高 $im->setCompressionQuality(100); $im->readImage($pdf); $m=md5($pdf); foreach ($im as $k => $v) { $v->setImageFormat('png'); $fileName = $path . $m.'.'.$k. '.png'; if ($v->writeImage($fileName) == true) { $return[] = $fileName; } } return $return; }{card-default label="使用方法" width="100%"}//用法 var_dump(pdf2png('1.pdf','test/')); /*返回 array(15) { [0]=> string(43) "test/f690229642a2b8bc66e9fbb05793266b.0.png" [1]=> string(43) "test/f690229642a2b8bc66e9fbb05793266b.1.png" [2]=> string(43) "test/f690229642a2b8bc66e9fbb05793266b.2.png" [3]=> string(43) "test/f690229642a2b8bc66e9fbb05793266b.3.png" [4]=> string(43) "test/f690229642a2b8bc66e9fbb05793266b.4.png" } */{/card-default}